Previous discussion on the same topic: A "for ... if" statement
For the given example, you could do
def print_evens(x: list[int]) -> None:
print(*[i for i in x if i % 2 == 0], sep="\n")
Previous discussion on the same topic: A "for ... if" statement
For the given example, you could do
def print_evens(x: list[int]) -> None:
print(*[i for i in x if i % 2 == 0], sep="\n")