input items in the empty list
#input items in the empty list which we call lst[]
# creating an empty list
lst = []
# number of elemetns as input
n = int(input("Enter number of elements : "))
# iterating till the range
for i in range(0, n):
ele = int(input("give me a food"))
lst.append(ele) # adding the element
print(lst)
(copy and past the code into the jupyter to see how it works)
Main Source Code:
menu_keys = {'cake':['bread', 'flour', 'ice'],
'icecream':['ice', 'flour', 'suji'],
'custardcoke':['coke', 'bread', 'flour', 'suji']}
# creating an empty list
lst = [] #this is equivalent to value in a dictionary.
# number of elemetns as input
n = int(input("Enter how many items u have in the fridge : "))
# iterating till the range
for i in range(0, n): #number of times it should loop/rotate
ele = str(input("give me fridge items"))
lst.append(ele) # adding the element to the lst = [], which is our list where we save our new inputs
for key in menu_keys:
if lst == menu_keys[key]: #menu_keys[key] is actually the value for the keys of menu_keys dictionary
print("you can make:", key)
break
else:
print("u cant make:", key)
No comments:
Post a Comment