1. Types & annotations
x: int = 42
items: list[int] = [1, 2, 3]
2. match / case
match status:
case 200:
print("ok")
case _:
print("other")
3. Comprehensions
squares = [n * n for n in range(10) if n % 2 == 0]
4. Exceptions
try:
1 / 0
except ZeroDivisionError as e:
print(e)
finally:
print("cleanup")
Loading comments...