Hello,

I am a beginner in python.
following program prints the second element in list of lists 4 for the
first elements in list 4 that are common with the elements in list 5


list4 = [['1', 'a'],['4', 'd'],['8', 'g']]
list5 = ['1', '2', '3']

for j in list4:
        for k in list5:
                if j[0] == k:
                        print j[1]

Result: a

I would like to do the same thing starting with following lists, where
the numbers in list 5 are without ''. Is there a way to convert
integers in a list to integers in '' ? This is based on a situation
where I want to find common numbers between a list and a list of lists
where the numbers in the list are without '' and the numbers in the
list of lists are with ''


list4 = [['1', 'a'],['4', 'd'],['8', 'g']]
list5 = [1, 2, 3]

This might be a stupid question, but anyway, thanks for your answer
It is not my first post on this site. In some way it is not possible
to react on the messages that I receive to thank the persons that
react. Anyway, thanks a lot


--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to