can someone tell me why this doesn't work please python 3

Gary M. Josack gary at byoteki.com
Wed Jan 14 09:44:29 EST 2009


garywood wrote:
> def ask_ok(prompt, retries=4, complaint="Yes or no, please!"):
>     while True:
>         password = input("enter something")
>         if password in ('y', 'ye', 'yes'): return True
>         if password in ('n', 'no', 'nope'): return False
>         retries = retries - 1
>         if retries < 0:
>             raise IOError('refusenik user')
>         print(complaint)
> ------------------------------------------------------------------------
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>   
Well since you didn't give an error I'm going to assume your problems 
are as follows:
* Use raw_input() instead of input() # input evals the input received.
* pass prompt as the argument to raw_input so that your prompt gets set 
# might want to give prompt a default value
* password.lower() so Y, YE, YES, N, NO, NOPE also work for input



More information about the Python-list mailing list