print first 10 elements of list python code example
Example 1: python first n elements of list
a=list((1, 2, 3))
n=1
a[:n]
output:
[1]
Example 2: python get first n elements of list
l = [1, 2, 3, 4, 5]
print(l[:3])
a=list((1, 2, 3))
n=1
a[:n]
output:
[1]
l = [1, 2, 3, 4, 5]
print(l[:3])