Python double/nested for loop list comprehension
Single for-loop with if condition
my_list = []
for x in range(3):
if x % 2 == 0:
my_list.append(x)
In List comprehension
>>> my_list = [x for x in range(3) if x % 2 == 0]
>>> my_list
[0, 2]
Single for-loop with if-else conditions
my_lis...
soumendrak.hashnode.dev2 min read