newbie Q: how do you re prompt user?
Jonathan Driller
jdriller at orchid.org
Sun Oct 20 23:13:31 EDT 2002
I am just getting started so a very basic Q:
If I write something that prompts a user for a response and then use
the same function later it does not work...how come? I have tried
encapsulating this in a def and then calling itself at the end but
that did not work either...
#import sleep function so we can remind hiring manager... ;-)
from time import sleep
x = raw_input("Wanna hire someone who likes Python and likes to
learn?") #use function to get input
negative = '' #assignment of empty char to initialize
positive = ''
#loop thru all no possibilities (crude) and assign n if no
if x == 'n':
negative == 'n'
elif x == 'No':
negative == 'n'
elif x == 'NO':
negative == 'n'
else:
negative = ''
while negative == 'n':
print "Please reconsider your choice"
#loop thru all yes possibilities (crude) and assign y if yes
if x == 'y':
positive = 'y'
elif x == 'yes':
positive = 'y'
elif x == 'Yes':
positive = 'y'
elif x == 'YES':
positive = 'y'
else:
print "Please reconsider that answer"
while positive == 'y':
print "Great, email Jonathan now!"
print "he is waiting at xxxxxx.org"
sleep(300)
print "Did you email Jonathan yet?"
#rerun function
x = raw_input("Wanna hire someone who likes Python and likes to
learn?")
More information about the Python-list
mailing list