In my post tqdm is a link. Just go and see it.
Try/except construction allows you to catch the errors or a specific error. A simple example will explain it better. My English is not so good as I want.
This can replace the if/elif/else in most of the cases.
Try/except construction allows you to catch the errors or a specific error. A simple example will explain it better. My English is not so good as I want.
try: num = float(input('Input a number: ')) num2 = float(input('A second please: ')) result = num / num2 print(f'{num} / {num2} = {result}') except ValueError: print('Incorect input. Abort!') except ZeroDivisionError: print('Zerro division not allowed. Abort!') finally: print('We did some nice math. Buy!')So you try to run some block of code and if there is an error you catch it and can take some actions.
This can replace the if/elif/else in most of the cases.