parse list recurisively

andypu at zoho.com andypu at zoho.com
Mon Sep 23 10:07:04 EDT 2013


thanks i was not able to figure it out some days before but now i think i can do it myself: a nice function that searches a string in a list.

def parsesb(lis, string):
	print lis 
	for num, nam in enumerate (lis):
		print num, nam
		if type(nam) == list: parsesb(lis[num],string)
		if type(nam) == str: # do something
			if nam == string: print 'hit!!!'



More information about the Python-list mailing list