python array get first n elements code example
Example 1: how to get first element of array in python
arr = ["cat", "dog", "rabbit"]
first_element = arr[0]
Example 2: python get first n elements of list
l = [1, 2, 3, 4, 5]
print(l[:3])
arr = ["cat", "dog", "rabbit"]
first_element = arr[0]
l = [1, 2, 3, 4, 5]
print(l[:3])