Today we’ll be talking about single statement suites.
If the suite (block of code) following the if, for or while statement consists only of one line of code, we can place it on the same line as the statement, immediately after the colon:
>>> if 2 + 2 == 4 : print("Yes")
...
Yes
The following code falls into an infinite loop, so you’d better not run it. Instead of writing:
number = 1
while number == 1:
print(number)
you could write:
number = 1
while number == 1: print(number)
Here’s an example with a for loop:
for iin range(5) : print(i)