Une list comprehension python code example
Example 1: python creare una list comprehension
quadrati = [n**2 for n in range(10)]
print(quadrati)
[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]
Example 2: python creare una list comprehension
quadrati = []
for n in range(10):
quadrati.append(n**2)
print(quadrati)
[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]