مثال از لیست کامپرهنشن
# with while loop
i = 1
result = list()
while i ** 2 < 620:
result += [i * 2]
i += 1
# with for loop
result = list()
n = range(1, 1000)
for i in n:
if i ** 2 <= 620:
result += [i * 2]
# with list comprehension
result = [i * 2 for i in list(range(1, 1000)) if i ** 2 < 620]