-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path010.loops2.py
42 lines (33 loc) · 944 Bytes
/
010.loops2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
shopping_list = ["milk","pasta","eggs","spam","bread","rice"]
#continue
for item in shopping_list:
if item == "spam":
continue
print("Buy "+item)
print("*"*50)
#break
item_to_find = "spam"
found_at = None
# for index in range(len(shopping_list)):
# if shopping_list[index] == item_to_find:
# found_at=index
# break
if item_to_find in shopping_list:
found_at = shopping_list.index(item_to_find)
if found_at is not None:
print("Item found at position {}".format(found_at))
else:
print("{} not found".format(item_to_find))
print("*"*50)
#while loop
chosen_item = None
while chosen_item not in shopping_list:
chosen_item = input("please input a item from shopping list to buy ")
if chosen_item.casefold() == "quit":
print("Exiting...")
break
print("Let's Buy {}".format(chosen_item))
for i in range(0, 100, 7):
print(i)
if i > 0 and i % 11 == 0:
break