不涉及函数应用
1 Food_list = { 2 'pizza': ['cheese', 'onion', 'green_papper', 'mushroom'], 3 'hamburger': ['beef', 'pork', 'chicken', 'lettuce', 'tomato', 'cheese', 'onion', 'cucumber'], 4 'pasta': ['fish', 'beef', 'onion', 'basil', 'meatball', 'black_papper'], 5 'fried_chicken': ['leg', 'wings', 'breast', 'chili', 'papper'], 6 'ice_cream': ['vanilla', 'Chocolate', 'strawbarry', 'banana'], 7 'french_fries': ['small_portion', 'medium', 'large_portion'], 8 'cake': ['cream', 'chocolate', 'mango', 'toon'], 9 'drinks': ['cola', 'sprite', 'coffee', 'milkshake'] 10 } 11 # print menu 12 for key in Food_list.keys(): 13 print(key.title()) 14 choice = input('Please choose you favorite food:\n') 15 16 Food_select = { 17 'pizza': [], 18 'hamburger': [], 19 'pasta': [], 20 'fried_chicken': [], 21 'ice_cream': [], 22 'french_fries': [], 23 'cake': [], 24 'drinks': [] 25 } 26 Drop_out = True 27 # Enter a list according to the user 28 while Drop_out: 29 if choice.isalpha(): 30 if choice == 'q': 31 for key in list(Food_select.keys()): 32 if not Food_select.get(key): 33 del Food_select[key] 34 print(Food_select) 35 Drop_out = False 36 break 37 elif choice == 'b': 38 print('You have returned to the top') 39 else: 40 # choice = choice.title() 41 print(Food_list[choice]) 42 choice2 = input( 43 'Please choose the ingredients you like:\nDrop out:q\nReturn to superior:b\n') 44 if choice2.isalpha(): 45 if choice2 == "q": 46 for key in list(Food_select.keys()): 47 if not Food_select.get(key): 48 del Food_select[key] 49 print(Food_select) 50 Drop_out = False 51 break 52 elif choice2 == "b": 53 for key in Food_list.keys(): 54 print(key) 55 choice = input('Please choose you favorite food:\n') 56 else: 57 while choice2 in Food_list[choice]: 58 Food_select[choice].append(choice2) 59 print(Food_select[choice]) 60 61 if choice2 not in Food_list[choice]: 62 print('Please select according to the ingredient list!') 63 break 64 else: 65 print('Please follow the menu order!') 66 67 else: 68 print('Please follow the menu order!')
Food_list = {
'pizza': [
'cheese',
'onion',
'green_papper',
'mushroom'],
'hamburger': [
'beef',
'pork',
'chicken',
'lettuce',
'tomato',
'cheese',
'onion',
'cucumber'],
'pasta': [
'fish',
'beef',
'onion',
'basil',
'meatball',
'black_papper'],
'fried_chicken': [
'leg',
'wings',
'breast',
'chili',
'papper'],
'ice_cream': [
'vanilla',
'Chocolate',
'strawbarry',
'banana'],
'french_fries': [
'small_portion',
'medium',
'large_portion'],
'cake': [
'cream',
'chocolate',
'mango',
'toon'],
'drinks': [
'cola',
'sprite',
'coffee',
'milkshake']
}
# print menu
for key
in Food_list.keys():
print(key.title())
choice =
input(
'Please choose you favorite food:
\n
')
Food_select = {
'pizza': [],
'hamburger': [],
'pasta': [],
'fried_chicken': [],
'ice_cream': [],
'french_fries': [],
'cake': [],
'drinks': []
}
Drop_out =
True
# Enter a list according to the user
while Drop_out:
if choice.isalpha():
if choice ==
'q':
for key
in
list(Food_select.keys()):
if
not Food_select.get(key):
del Food_select[key]
print(Food_select)
Drop_out =
False
break
elif choice ==
'b':
print(
'You have returned to the top')
else:
# choice = choice.title()
print(Food_list[choice])
choice2 =
input(
'Please choose the ingredients you like:
\n
Drop out:q
\n
Return to superior:b
\n
')
if choice2.isalpha():
if choice2 ==
"q":
for key
in
list(Food_select.keys()):
if
not Food_select.get(key):
del Food_select[key]
print(Food_select)
Drop_out =
False
break
elif choice2 ==
"b":
for key
in Food_list.keys():
print(key)
choice =
input(
'Please choose you favorite food:
\n
')
else:
while choice2
in Food_list[choice]:
Food_select[choice].append(choice2)
print(Food_select[choice])
if choice2
not
in Food_list[choice]:
print(
'Please select according to the ingredient list!')
break
else:
print(
'Please follow the menu order!')
else:
print(
'Please follow the menu order!')