My first script (so go easy on me!)

Tyler Eaves tyler at tylereaves.com
Tue Jan 16 11:11:41 EST 2001


A real problem I notice is this block of code right here. The problem
is that for example, the following would all restart the daemon:
yes
heck no
nope
etc
basically, anything more than 2 characters long

>if len(answer) > 2:
>    print r
>elif len(answer) < 2:
>    print w
>else:
>    print n
>
A much better way to do this would be:

import string
answer=string.lower(answer)
if answer=='yes':
	print r
elif answer=='no':
	print w
else:
	print n



More information about the Python-list mailing list