[Tutor] finding a non-letter?

alan.gauld@bt.com alan.gauld@bt.com
Thu, 3 Oct 2002 11:45:53 +0100


> str[0], but how would test to see if it's a non-letter?

import string
if str[0] not in string.letters: # do whatever


OR

if str[0] in string.numbers: # do it

the first tests any non letter(punctuation etc)the 
second is specifically for numbers.

try

dir(string)

to see the other predefined collections.

HTH

Alan g.
Author of the 'Learning to Program' web site
http://www.freenetpages.co.uk/hp/alan.gauld