View Single Post
Old Jun 8th, 2006, 11:14 PM   #3
titaniumdecoy
Expert Programmer
 
titaniumdecoy's Avatar
 
Join Date: Nov 2005
Posts: 929
Rep Power: 4 titaniumdecoy is on a distinguished road
Send a message via AIM to titaniumdecoy
I've solved the problem by rewriting the function using filter():

for i in range(len(num)):
	letters = numdict[int(num[i])]
	namelist = filter(lambda w: w[i] in letters, namelist)
I am still puzzled as to why the previous function I wrote does not work, however. I have done extensive debugging and everything seems fine, except the output.

EDIT: Ooops, Sane: It looks like you were right. I was still trying to remove from the list I was iterating through... The working function is as follows:

nc = list(namelist)
for i in range(len(num)):
	letters = numdict[int(num[i])]
	for name in nc:
		if name in namelist and name[i] not in letters:
			namelist.remove(name)
titaniumdecoy is online now   Reply With Quote