Change square brackets to parentheses

Minor change to avoid unnecessary confusion by conditional statements not executing properly if a beginner programmer uses square brackets rather than parentheses to enclose a condition.
This commit is contained in:
bearbybits
2021-09-16 16:05:25 -07:00
committed by GitHub
parent 54644d4754
commit d7bbff839f

View File

@@ -986,9 +986,9 @@ nature of the tab-based indentation, ``elif`` can be used instead of
::
if [expression]:
if (expression):
statement(s)
elif [expression]:
elif (expression):
statement(s)
else:
statement(s)
@@ -1003,7 +1003,7 @@ Short statements can be written on the same line as the condition::
Sometimes, you might want to assign a different initial value based on a
boolean expression. In this case, ternary-if expressions come in handy::
var x = [value] if [expression] else [value]
var x = (value) if (expression) else (value)
y += 3 if y < 10 else -1
Ternary-if expressions can be nested to handle more than 2 cases. When nesting