The list derivation is Python One of the characteristics of , Is that we can construct a list succinctly .
L=[]
for x in range(5):
L.append(x)
print(L)
[0, 1, 2, 3, 4]
# Use list derivation to achieve the above effect
[x for x in range(5)]
[0, 1, 2, 3, 4]
# Set derivation
{
x*x for x in range(5)}
{0, 1, 4, 9, 16}
# Dictionary derivation
x:x*x for x in range(5)}
{
0: 0, 1: 1, 2: 4, 3: 9, 4: 16}