0
If âxâ:
If I make a piece of code that goes If âxâ: print(âIâm a penguinâ) And I run the code, the message is printed Why? What does if âxâ: actually mean? I havenât given x any value, so what about this undefined x causes the print function to work?
1 Answer
+ 1
Didn't work when I tested it in Playground. Error "Invalid character ..."
(Edit)
Apparently the problem lied in the print function call. You are using a slanted double quote for the string "I'm a penguin". It works as I changed that to regular double quote character.
Apparently "x" here is a string, Python considers it as boolean True because it is not an empty string.



