Answers for "how to print the first thing in a list python"

1

how to take index first and last in python in one way

[some_list[0], some_list[-1]]
Posted by: Guest on January-04-2021
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
2

Python get first element from list

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

Code answers related to "how to print the first thing in a list python"

Python Answers by Framework

Browse Popular Code Answers by Language