Apr-09-2019, 07:58 PM
You are converting on line 4, you want that in the try block. An error on either one will trigger the except part, so you just need one of those. You also need a break statement.
try: val1, val2 = [int(x) for x in input("Please enter two numbers: ").replace(",", " ").split()] break except ValueError: print('Please enter valid numbers.')If the error happens on the second line, it will skip to the except. If it doesn't happen (valid input), it will break out of the loop.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures