+ 1
What's wrong with my python calculator code?
It says invalid syntax, I would like to know why... CODE{ #Some input variables if operation == "addition" result = numberone + numbertwo print(result) }
5 Answers
+ 1
Your if statements, elif, and else statements need a ":" after them
numberone = int(input("Write a number"))
numbertwo = int(input("Write a number to calculate with your first number"))
operation = (input("Math Operation \(addition,subtraction,multiplication,division)"))
if operation == "addition":
result = numberone + numbertwo
print(result)
elif operation == "subtraction":
result = numberone - numbertwo
print(result)
elif operation == "multiplication":
result = numberone * numbertwo
print(result)
elif operation == "division":
result = numberone / numbertwo
print(result)
else:
print("Not a valid operation")
+ 2
Linking to the code will be easier to debug than pseudo code
+ 1
Noob mistake, can't believe I forgot it...
Thanks very much for the help and sorry for the inconvenience...
0
Basic noob beginner code...