Input Validation Tutorial for Python

Veröffentlicht am: 14 Februar 2024
auf dem Kanal: Byte_Logic
35
1

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)


Auf dieser Seite können Sie das Online-Video Input Validation Tutorial for Python mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Byte_Logic 14 Februar 2024 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 35 Mal angesehen und es wurde von 1 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!