I am trying to make a calculator and the user must input which operation they want to use, I have only done addition so far but you get the point.
welcome = str(input("Welcome to the calculator, which form of operation do you wish to choose? "))
Addition = "Add", "add", "Addition", "addition", " "
for x in Addition:
if welcome == Addition:
print("Works")
I run the code and when I input any of the strings in the "Addition" variable, it does not print "Works"?.
I have tried without the for loop and it still does not print "Works"
I am an absolute beginner at python and I just made this stackoverflow account today. I don't know how to write the code in proper code form in this question.
CodePudding user response:
You are probably looking for in
we can also use .lower()
on the input so we have fewer things to match.
welcome = str(input("Welcome to the calculator, which form of operation do you wish to choose? ")).lower()
addition = ['add','addition',' ']
if welcome in addition:
print('worked')