looping question 4 NEWB

manstey manstey at csu.edu.au
Thu Jul 6 06:43:14 EDT 2006


Hi,

I often have code like this:

data='asdfbasdf'
find = (('a','f')('s','g'),('x','y'))
for i in find:
   if i[0] in data:
       data = data.replace(i[0],i[1])

is there a faster way of implementing this? Also, does the if clause
increase the speed?

Thanks,
Matthew




More information about the Python-list mailing list