if
if x < 0:
x = 0
print('Negative changed to zero')
elif x == 0:
print('Zero')
else: //Optional
print('More')
for statement
words = ['cat', 'window', 'defenestrate'] //Iterate over list
for w in words:
print(w, len(w))
for i in range(0, 4): //Iterate over range
print (i) #0,1,2,3
str = "abc"
for i in reversed(str): //Reverse Print
print (i) //cba
match statement
def http_error(status):
match status:
case 400:
return "Bad request"
case 404:
return "Not found"
case 418:
return "I'm a teapot"
case _:
return "Something's wrong with the internet"
range statement
iterate over a sequence of numbers
>>> for i in range(5):
... print(i)