Merging lists has made my brain hurt.

Huw Lynes huw-l at moving-picture.com
Thu Oct 3 13:41:29 EDT 2002


Thanks to everyone that gave advice.

I've decided to go with a slightly more verbose version of what Brian E 
Gallew proposed. namely:

while len(lol) > 1:
		list1 = lol.pop()
		list2 = lol.pop()
		list3 = []
		for x in list1:
			if x in list2:
				list3.append(x)
		lol.append(list3)

final_list = lol.pop()

The set stuff looks interesting and I will take a look at it when I get 
the chance. For now the method above solves my problem in a way that is 
simple enough for me to understand in three months time when I come back 
to make changes to what I've just written.

Thanks,
Huw




-- 
| Huw Lynes               | The Moving Picture Company  |
| System Administrator    | 127 Wardour Street          |
|.........................| London, W1F 0NL             |





More information about the Python-list mailing list