Python uses while to cycle orders and count them in the list

CSDN Q & A 2022-05-14 15:50:47 阅读数:512


s1mple = [('apple', 2.10), ('milk', 4.50), ('banana', 10.50)]

The order code is :(input)
Enter order for apple:
Enter order for milk:
Enter order for Krusty:

Put the above three input In the list, Such as [1,1,1,]
Application def, and menu by s1mple
The renderings are as follows


Take the answer :
def get_order(menu:list) -> list:  return [int(input(f'Enter order for {i[0]}:')) for i in menu]sample = [('apple', 1.50),('orange',2.90)]check = get_order(sample)print(check)

版权声明:本文为[CSDN Q & A]所创,转载请带上原文链接,感谢。