list get first element python 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 element in a list
test_list = [1, 5, 6, 7, 4]
print ("The original list is : " + str(test_list))
res = [ test_list[0], test_list[-1] ]
print ("The first and last element of list are : " + str(res))
Example 3: how to find first value of an list
list = [1,2,3]
firstdigit = list[0]
list = ['Hello', 'bye', 'Adios']
firstvalue = list[0]