vendredi 3 août 2018

Syntax Error in Inline if … else Syntax in Python

What exactly is wrong with the syntax and why in the following piece of code? I've counted the parentheses among other things yet am unable to figure it out.

c = ""
 print("Yes") if c else print("No")

Note: It gives a Syntax error like the one below:

print("Yes") if c else print("No")
                            ^
SyntaxError: invalid syntax

Aucun commentaire:

Enregistrer un commentaire