list comprehensions python 3 code example
Example 1: list comprehension
# List comprehension
list_comp = [i+3 for i in range(20)]
# above code is similar to
for i in range(20):
print(i + 3)
Example 2: list comprehension python 3
number_list = [x for x in range(10) if x % 2 == 0]
print(number_list)
Example 3: python list comprehension
h_letters = [ letter for letter in 'human' ]
print( h_letters)