In this video I'll be covering the try except logic in python. I will be using the templates discussed in our previous videos but don't worry, these concepts can be demonstrated on their own! I'll leave a copy paste template below (as usual).
The Try except logic can be used for may things; however, I seem to use it most for input validation. In my work and personal life, I use this small but effective logic structure as a soft guide for anyone else trying to run my code.
There are other uses as well; the except clause can be modified for greater error reporting.
Challenge:
Next time you're troubleshooting code, try putting sections of it in a try except clause BUT modify the except clause so that it reads as the following:
except Exception as exception:
print(exception)
This will give you a better explanation of what is breaking in your code an you can quickly narrow down your mistakes.
===============================================
global var1
Validation
validation2 = True
while validation2:
try:
var1 = input()
validation2 = False
except:
validation2 = True
==============================================
Please feel free to ask me any questions!
Link below for the template video \/
• Habits That Will Set You Apart In The Pyth... - the template itself
• Python | THE SECRET SAUCE!! - the looping logic video (very useful)
In questa pagina del sito puoi guardare il video online Input Validation Tutorial for Python della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Byte_Logic 14 febbraio 2024, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 35 volte e gli è piaciuto 1 spettatori. Buona visione!