0

Why can't I create variables? Syntax error but it should be correct.

So I'm starting out on Python and I can't seem to get my variables to work right. All I want is it do simple math problems to get the hang of Python, but it keeps reading syntax errors. Could you read my code and tell me what I am doing wrong? Forgive my noob-ness. https://code.sololearn.com/cPNIl67ScG7e

31st Oct 2018, 7:57 PM
Benji
Benji - avatar
2 Answers
+ 4
It doesn't seem that there is anything wrong with declaring your variable, but rather the if statement for checking the value of it. With Python, blocks of code are generally declared via a colon : following a statement, so the syntax for an if statement would be - if condition: statement(s) For your code, just add a colon at the end of the third line and it should work.
31st Oct 2018, 8:09 PM
Faisal
Faisal - avatar
+ 3
There's another mistake: You are declaring a string of 5, but in your if condition you are checking for the number five. So either you have to declare 5 or check for "5", otherwise you're comparing pears and apples. (If you actually wanted the if part to fail, I haven't said anything.)
31st Oct 2018, 8:52 PM
HonFu
HonFu - avatar