
February 3rd, 2013, 03:15 PM
|
 |
Contributing User
|
|
|
|
|
# If choice is 1 the loop exits.
while choice != 1 or choice == 2:
# therefore equivalent, but simple
while choice != 1:
Your code is for python3. input returns a string.
choice = input()
choice = str(choice) # unnecessary statement
I don't understand why you chose to define functions within the while loop. I suppose their variables take fresh values from the enclosing scope. The usual reason to define classes or functions within a function is for testing, to pass as a callable to another function, or to return a custom-made function. In this program the structure merely confuses me. See python decorators, for example, or functions of the functools module. So there it is, I didn't answer your question because I'm confused.
__________________
[code] Code tags[/code] are essential for python code!
|