python get first x elements of list code example
Example 1: python first n elements of list
a=list((1, 2, 3))
n=1
a[:n]
output:
[1]
Example 2: find the first element in phython list
Alist = ['Sun','Mon','Tue','Wed','Thu']
print("The given list : ",Alist)
print("The first element of the list : ",Alist[0])
print("The last element of the list : ",Alist[-1])
Example 3: how to find first element in a list python
an_array = [1,2,3,4,5]
first element = an_array[0]