+ 1
user_input == input(':') 1=add 2=subtract 3=multiply 4=divide 5=quit if user_input ==(5) break elif user_input ==(1) num1 = fl
why this get a syntax error
4 Respuestas
+ 1
First line, you don't need == since you don't test if it's equal but you assign it.
Next, I don't believe you can use numbers as variable names.
Finally, you need to add ':' at the end of the lines of your if and elif, and to indent the lines concerned by the condition.
+ 1
I believe you try to do some kind of basic calculator?
Your code is surely inside a while loop, it should look like something like that :
print("1=add")
print("2=substract")
print("3=multiply")
print("4=divide")
print("other=quit")
while True:
user_input = input("What do you want? ")
if(user_input == 1):
# Do the addition code
elif(user_input == 2):
# Do the substraction code
# Do the other cases
else:
break
0
i've changed the variable but I still get a syntax error
and it says that somehow user_input is wrong
0
thanks I was trying to short rhe basic calculator of the second part of the python course, sorry for wasting your time