I'm currently following Zed Shaw's book on Python, Learn Python the Hard Way and I'm learning about functions. I decided to follow some of the extra credit exercises that went along with the lesson and added an IF ELSE flow statement. This is the code I have below.
print "How much bottles of water do you have?"
water = raw_input("> ")
print "How many pounds of food do you have?"
food = raw_input("> ")
if food == 1:
def water_and_food(bottles_of_water, food):
print "You have %s bottles of water" % bottles_of_water
print "And %s pound of food" % food
else:
def water_and_food(bottles_of_water, food):
print "You have %s bottles of water" % bottles_of_water
print "And %s pounds of food" % food
water_and_food(water, food)
What I want to do is this. If the user inputs they have 1 pound of food, it will display "You have 1 pound of food" If they input they have 2 pounds of food or more, it will display "You have 2 pounds of food," the difference of pound being singular or plural.
However, if I put 1, it will still display "You have 1 pounds of food," however if I directly assign a number to the variables water and food, it will work.