[Tutor] Letters & Digits

alan.gauld@bt.com alan.gauld@bt.com
Sun, 18 Nov 2001 23:47:08 -0000


> clean and easy way to test each character in a string to 
> see if they match (or do not match) characters from those lists. 

import string
chars_of_interest = string.lowercase + string.digits

for c in myString:
   if c in chars_of_interest: break
   else: # do something

You could also use some of the functional programming 
things like comprehensions or map or filter

Alan g