Input Validation Tutorial for Python

Published: 14 February 2024
on channel: 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)


On this page of the site you can watch the video online Input Validation Tutorial for Python with a duration of hours minute second in good quality, which was uploaded by the user Byte_Logic 14 February 2024, share the link with friends and acquaintances, this video has already been watched 35 times on youtube and it was liked by 1 viewers. Enjoy your viewing!