Input Validation Tutorial for Python

Publicado em: 14 Fevereiro 2024
no canal de: 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)


Nesta página do site você pode assistir ao vídeo on-line Input Validation Tutorial for Python duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário Byte_Logic 14 Fevereiro 2024, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 35 vezes e gostou 1 espectadores. Boa visualização!