def product():
item = {
'Bananas': 3,
'Apples' : 2,
'Oranges' : 4,
'Pineapple' : 6,
'Strawberry' : 5
}
query1 = input('Write product: ')
query2 = int(input('Write quantity: '))
print(product())
答案 0 :(得分:1)
我假设您正在寻找True / False作为函数的结果。
def product():
item = { 'Bananas': 3, 'Apples' : 2, 'Oranges' : 4, 'Pineapple' : 6, 'Strawberry' : 5 }
query1 = input('Write product: ')
query2 = int(input('Write quantity: '))
if query1 in item:
if item[query1] == query2:
return True
return False
print(product())