I have a code for a self-service checkout:
price = {'meat': 3, 'bread': 1, 'potato': 0.5, 'water': 0.2}
def buy():
pay = 0
while True:
enter = input('Что покупаем???\n')
if enter == 'end':
break
pay += price[enter]
return pay
buy()
I wanted the code to return the price by keys (I indicated the product names with the keys, and the price with the values), but the return function does not work and the program ends