Jun-12-2018, 08:47 AM
To add a small comment, you have many chains of if, elif, elif... without a final else.
This can do debugging your code really painful, as some function will silently do nothing.
In a set of if/elif conditions if the final option is something that you do not expect is a good idea to raise an error or at least inform the user:
This can do debugging your code really painful, as some function will silently do nothing.
In a set of if/elif conditions if the final option is something that you do not expect is a good idea to raise an error or at least inform the user:
if answer in ('y', 'yes'): guessGame() elif answer in ('n', 'no'): wutNow() else: print(f'I do not understand {answer}. Please input yes or no')If your real intention is to do nothing you can add a pass statement:
if answer in ('y', 'yes'): guessGame() elif answer in ('n', 'no'): wutNow() else: # Ignore the user and continue with the program... passIn this way is clear that your intention is to do nothing, not that you forgot a condition. Obviously this is important for nested if/elif. You can do the same for a normal if/else, but usually is not necessary.