Answers for "Python get first element from list"

3

how to get first element of array in python

arr = ["cat", "dog", "rabbit"]
first_element = arr[0]
Posted by: Guest on October-01-2020
5

python get first element in a list

# Python3 code to demonstrate  
# to get first and last element of list 
# using list indexing 
  
# initializing list  
test_list = [1, 5, 6, 7, 4] 
  
# printing original list  
print ("The original list is : " +  str(test_list)) 
  
# using list indexing 
# to get first and last element of list 
res = [ test_list[0], test_list[-1] ]  
  
# printing result 
print ("The first and last element of list are : " +  str(res))
Posted by: Guest on April-13-2020
1

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])
Posted by: Guest on January-11-2021
2

Python get first element from list

list[0]
Posted by: Guest on September-12-2020

Code answers related to "Python get first element from list"

Python Answers by Framework

Browse Popular Code Answers by Language