Hello,
I'm very new to Python (meaning I just started class about a week ago) and I'm a little stuck on something that I'm hoping to get some direction on.
I'm trying to write a program that asks for user input for the names of two food names, then pushes them together to create a new word, outputting that to the user.
What I want to do is to make sure that the variables "food1" and "food2" cannot be the same exact thing. I thought to use an if/else statement, but I'm not sure how to express something along the same lines of "if food1 is the same thing as food2, output the statement 'You cannot use the same food twice.' and to ask for the user to input it again.
I think the problem is that the if/else statement seems to always be for mathematical expressions. Is there a way to perform this kind of statement with variable names alone as expressions?
Apologies for the noob question.
Also: Here's the code I'm using at the moment. Needless to say, the "=" is giving me a syntax error.
food1 = raw_input("Enter the name of one of your favorite foods: ")
print "One of your favorite foods is", food1 + "."
food2 = raw_input("Enter the name of another of your favorite foods: ")
if (food2 = food2):
print "That was your first food! Please enter a DIFFERENT food."
food2 = raw_input("Enter the name of another of your favorite foods: ")
else:
print "Your other favorite food is", food2
fuppercase = food1.upper()
print "\n\nConsider this: If you were to have a food specially engineered just for you, it could be called", food1 + food "or" food2 + food1 "."
print "\nIf it were printed on a label designed to catch someone's attention, it would be called", fuppercase "."
raw_input("Press enter to exit the program.")
I know there are probably other errors in the code, but for now I'd like to just focus on the if/else statement.
Thanks!