money = 170
KitKat = 90
choice1 = raw_input("Choose a snack: ")
Choose a snack: KitKat
if choice1 < money:
print ("Enjoy your snack")
else:
print ("You cannot afford ") + (choice1)
You cannot afford KitKat
This is a shortened version of a vending machine programme I am working on. You have a certain amount of coins, and it asks you to choose a snack. In this shortened program you always have 170 coins and you can only choose KitKat. It then checks if you can afford KitKat or not by comparing the variables: "money", and "choice1" to see which is bigger. If "money" is bigger, it should say "Enjoy your snack". But if "choice1" is bigger, it should say "You cannot afford KitKat".
The problem is, when I test it, it always thinks that "choice1" is greater than "money" and tells me that I "cannot afford KitKat".
I think maybe when I am inputting "KitKat" it doesn't recognise it as a variable and compares the word "KitKat" to the variable "money", instead of comparing the variable "KitKat" to the variable "money" But I'm not sure. Any ideas where I'm going wrong?