My question is how to print out something if nothing matched in for loop. For example:
a = {'store' : 'A', 'menu' : 'pizza', 'price' : 20000}
b = {'store' : 'B', 'menu' : 'chicken', 'price' : 18000}
c = {'store' : 'C', 'menu' : 'noodle', 'price' : 5000}
d = {'store' : 'D', 'menu' : 'sushi', 'price' : 15000}
e = {'store' : 'E', 'menu' : 'chicken', 'price' : 23000}
f = {'store' : 'F', 'menu' : 'pork', 'price' : 30000}
Total = [a, b, c, d, e, f]
l = input('what food?: ')
p = int(input('how much you want to spend? '))
for i in range(5):
if Total[i]['menu'] == l and int(Total[i]['price']) <= p:
print('menu', Total[i]['store'], 'price', Total[i]['price'])
after the loop, if there is no such store satisfying conditions, I want to print out 'There is no store'
.