Hi - I found an error in the Chap 4 prob 5 exercise. I had to use the type conversion, list, in the 3rd line:
Code:
fridge={"spaghetti":"only 2 weeks old","milk":"6 weeks past expiration", "butter":"probably ok","lettuce":"yuk!", "beer":"ice cold six pack of Corona"}
food_sought="tomato"
fridge_list=list(fridge.keys())
items=len(fridge_list)-1
i=0
while i <= items:
if food_sought == fridge_list[0]:
print("%s found! %s " % (food_sought, fridge[food_sought]))
break
fridge_list.pop(0)
i=i+1
else:
print("%s not found." % food_sought)