list = [[1,'abc'], [2, 'bcd'], [3, 'cde']]
I have a list that looks like above.
I want to parse the list and try to get a list that only contains the second element of all lists.
output = ['abc','bcd','cde']
I think I can do it by going over the whole list and add only the second element to a new list like:
output = []
for i in list:
output.append(i[1])
something like that, but please tell me if there is a better way.
listas a variable name isn't recommended. You could always do[x[1] for x in my_list], orlist(map(lambda x: x[1],my_list))if you are in a Lispy mood.