Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

get first element of list of lists python

# Python3 program to extract first and last
# element of each sublist in a list of lists
 
def Extract(lst):
    return [item[0] for item in lst]
     
# Driver code
lst = [[1, 2], [3, 4, 5], [6, 7, 8, 9]]
print(Extract(lst))
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #element #list #lists #python
ADD COMMENT
Topic
Name
9+5 =