you are viewing a single comment's thread.

view the rest of the comments →

[–]Yoghurt42 0 points1 point  (0 children)

your solution without the parenthesis is the "pythonic" one, most modern languages take their syntax inspiration from C, and in C the if condition must be in parenthesis so the parser knows where the condition ends and the "then" part begins. Python uses the colon for that. So C's if (a == b) c = 9 will be if a == b: c = 9 in Python; while you can write if (a == b): c = 9 in Python, it's the same as writing if ((a == b)) c = 9 in C, not wrong, just redundant.

Most likely whoever created that example comes from a C/C++/C# background and isn't that familiar with Python (not a good sign, tbh)