Skip to main content

Timeline for Console-based hangman in Python

Current License: CC BY-SA 4.0

3 events
when toggle format what by license comment
Jan 6, 2020 at 14:56 comment added Barb docs.python.org/3/tutorial/errors.html Here is some documentation on try and except clauses. In the code above I have basically forced the user to input integers only and stay in the loop while checking that the conditions are met. Generally try/exceptions are used for specific conditional errors. It just saves time from creating a conditional type function. For instance not matter what you enter into str(input('')) it will be treated as a string. You then have to check if the input .isdigit() or convert it, handling it accordingly. Read some of the documentation its very helpful
Jan 6, 2020 at 4:10 comment added Roddy of the Frozen Peas In your try-catch example, the exception is raised if the input is not an integer. However all of my inputs are strings, so I don't really understand how I could go about using try-catch in this fashion unless I start raising the exceptions myself. Does Python really recommend using exception handling for control flow in this way? I've always understood this to be an anti-pattern and bad practice.
Jan 5, 2020 at 14:15 history answered Barb CC BY-SA 4.0