How to print an element from a list of lists in python

Asked

Viewed 1,502 times

1

I have a list of lists, like: [ ('name1',size1), ('Nome2', size2)]

I want to print just the name of each list, how could I do it?

1 answer

1


You can do it this way:

l = [('nome1', 1), ('nome2', 2)] # Cria lista de tuplas
for t in l:
   print(t[0]) # Imprime o primeiro elemento da tupla

Browser other questions tagged

You are not signed in. Login or sign up in order to post.