Best way to do this?

sambo sambo at void.com
Thu Jan 22 19:39:20 EST 2004



>
>The "obscure" for/else can help:
>
>
>def get_password (prompt):
>    for i in (1, 2, 3):
>        password = raw_input (prompt)
>        if password == 'mypass':
>            return True
>        else:
>            print "Try Again"
>    else:
>        print "Too Bad"
>        return False
>
>
>
>        Regards.        Mel.
>
Obscure? at least it does something.

What is the advantage of the following assignment ( a few messages up)

attempts, password = 3, 'mypass'

Reading difficulty - at least 3 (no relation, hehe)

Ciao






More information about the Python-list mailing list