+ 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) }

2nd Sep 2019, 7:43 PM
MarkusKohl
MarkusKohl - avatar
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")
2nd Sep 2019, 7:48 PM
Ole113
Ole113 - avatar
+ 2
Linking to the code will be easier to debug than pseudo code
2nd Sep 2019, 7:46 PM
Ole113
Ole113 - avatar
+ 1
Noob mistake, can't believe I forgot it... Thanks very much for the help and sorry for the inconvenience...
2nd Sep 2019, 7:50 PM
MarkusKohl
MarkusKohl - avatar
2nd Sep 2019, 7:47 PM
MarkusKohl
MarkusKohl - avatar
0
Basic noob beginner code...
2nd Sep 2019, 7:47 PM
MarkusKohl
MarkusKohl - avatar