Print the first element from each nested list in Python list

Last Updated On Thursday 20th Jan 2022

Example 1

	list=[1,2,3,[4,5,6],7,8,[9,10]]
for i in range(0,len(list)):
    if type(list[i]) != int:
        print(list[i][1])
	

Output

	5
10
	

Example 2

	list=[11,21,13,[14,25,36],87,88,[79,100]]
for i in range(0,len(list)):
    if type(list[i]) != int:
        print(list[i][0])
	

Output

	14
79