liste python compréhension code example
Example 1: list comprehensions
h_letters = [ letter for letter in 'human' ]
print( h_letters)
Example 2: list comprehension in python
Squaring List elements:
By loop:
lst = [1, 2, 3]
l =[]
for i in lst:
lst.append(i*i)
print(l)
By List Comprehension:
lst = [1, 2, 3]
l = [x*x for x in lst]
print(l)