loop try except code example
Example: how to use try except in while loop in python
while True: try: num = int(input("Enter an int: ")) except Exception as e: print(e) else: print("Thank you for the integer!") break# Enter an int: a# invalid literal for int() with base 10: 'a'# Enter an int: 3# Thank you for the integer