+ 2

Invalid syntax in multiple if statements

num = 12 if num > 5: print("Bigger than 5") if num <=47: print("Between 5 and 47") if num = 12 print("yeboi") Why do I get invalid syntax pointing to the = sign?

27th Feb 2018, 12:13 PM
Adithiya Vikash
Adithiya Vikash - avatar
6 ответов
+ 9
write "num == 12:" instead of "num = 12" And please specify the language of this code. Many people may not understand its python.
27th Feb 2018, 12:18 PM
cHiRaG GhOsH
cHiRaG GhOsH - avatar
+ 5
@adithiya you forgot colon :
27th Feb 2018, 12:28 PM
cHiRaG GhOsH
cHiRaG GhOsH - avatar
27th Feb 2018, 3:32 PM
📈SmileGoodHope📈
📈SmileGoodHope📈 - avatar
+ 1
Ah yes I forgot to specify the language. Thanks
27th Feb 2018, 12:24 PM
Adithiya Vikash
Adithiya Vikash - avatar
+ 1
num = 12 if num > 5: print("Bigger than 5") if num <=47: print("Between 5 and 47") if num == 12 print("yeboi") Eh but the syntax error here points at the integer 2 I tried what you said and still got an error
27th Feb 2018, 12:27 PM
Adithiya Vikash
Adithiya Vikash - avatar
+ 1
Oh no wonder lol thanks. Haiz I go java curly bracket is a pain now in python cuz of a colon a whole code errors out
27th Feb 2018, 12:29 PM
Adithiya Vikash
Adithiya Vikash - avatar