newbie Q: how do you re prompt user?

Dennis Lee Bieber wlfraed at ix.netcom.com
Sun Oct 20 23:43:33 EDT 2002


Jonathan Driller fed this fish to the penguins on Sunday 20 October 
2002 08:13 pm:

> 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...
>

        Because you are only rerunning the "input request", you aren't 
rerunning all the code with it.

        -=-=-=-=-==-=-=-

import time

while 1:
        ans = raw_input("Want to hire...")

        if ans[0] == "n" or ans[0] == "N":
                print "Please reconsider..."
        elif ans[0] == "y" or ans[0] == "Y":
                print "Great, email <someone>..."
                print "he is at ...."
                time.sleep(300)
                print "Did you email yet?"
                break
        else:
                print "invalid response, try again"

                
                
-- 
--  
 > ============================================================== <
 >   wlfraed at ix.netcom.com  | Wulfraed  Dennis Lee Bieber  KD6MOG <
 >      wulfraed at dm.net     |       Bestiaria Support Staff       <
 > ============================================================== <
 >        Bestiaria Home Page: http://www.beastie.dm.net/         <
 >            Home Page: http://www.dm.net/~wulfraed/             <



More information about the Python-list mailing list