How to Validate User Inputs in Python | Input Validation in Python

  Рет қаралды 36,287

Fabio Musanni - Programming Channel

Fabio Musanni - Programming Channel

Жыл бұрын

💻 Get the Source Code and support the channel ❤️: www.buymeacoffee.com/fabiomus...
⬇️ LEARN ON THE BEST LEARNING PLATFORMS (LINKS BELOW) 😉💪 ⬇️
💻 My Source Codes: www.buymeacoffee.com/fabiomus...
☕ Buy me a coffee: www.buymeacoffee.com/fabiomus...
😍 One-off donation: www.paypal.me/FabioMusanni/
SKILLSHARE
(Python, Web Dev, UI/UX Design, Music, Art, Animation and a lot more)
🔗 skillshare.eqcm.net/5gxzD2 (Affiliate)
DATACAMP
(Python, ChatGPT, SQL, Power BI, and a lot more)
🔗 datacamp.pxf.io/vN1bDj (Affiliate)
COURSERA PYTHON
(For beginners, Data Science, Data Analysis, AI, Cybersecurity and a lot more):
🔗 imp.i384100.net/k0Nk60 (Affiliate)
COURSERA WEB DEVELOPMENT
(Full Stack, Front-End, Back-End, Web Design and a lot more):
🔗 imp.i384100.net/EKWxBW (Affiliate)
Learn how to validate inputs entered by the user like not allowing inputs that contain certain characters, allowing only numbers and a lot more.
Complete list of what you'll learn:
- Allow only numbers
- Allow anything but numbers
- Not allow inputs that contain certain invalid characters
- Allow only certain values
If the video was helpful, let me know in the comments down below and also like the video so that other people can see it. Needles to say I really appreciate your support 💪❤️
📨 SUBSCRIBE so that you don't miss any new video:
kzfaq.info...
🤗 BIO PAGE (contacts, etc): solo.to/fabiomusanni
Create Your Bio Page (10% OFF Upgraded Plans 😉): solo.to/inv/NDE4NzE2
🔗 RELATED CONTENT (videos, playlists, etc) 🔗
Hangman Game Tutorial: • Python Hangman Game Tu...
Python Playlist: • 🐍 Learn Python With Fa...
🤩 AFFILIATE LINKS 🤩
Create Your Bio Page (10% OFF Upgraded Plans): solo.to/inv/NDE4NzE2
🧑🏻‍💻 ABOUT ME 🧑🏻‍💻
I'm Fabio, I started programming with Python a lot of years ago and I fell in love with this world.
I started this KZfaq channel to help you during your own journey and I hope that my help can make you an amazing programmer who loves this world as I do.
Welcome on board!! 🚀
#pythonWithFabioMusanni #python #pythonforbeginners #pythontutorial #pythonprogramming #coding #programming

Пікірлер: 42
@FabioMusanni
@FabioMusanni Жыл бұрын
💻 *Source Code:* www.buymeacoffee.com/fabiomusanni/e/185794 ⬇️ *LEARN ON THE BEST LEARNING PLATFORMS (LINKS BELOW)* 😉💪 ⬇️ ☕ *Buy me a coffee:* www.buymeacoffee.com/fabiomusanni ❤️ *Support me monthly:* www.patreon.com/FabioMusanni 😍 *One-off donation:* www.paypal.me/FabioMusanni/ *SKILLSHARE* _(Python, Web Dev, UI/UX Design, Music, Art, Animation and a lot more)_ 🔗 skillshare.eqcm.net/5gxzD2 (Affiliate) *DATACAMP* _(Python, ChatGPT, SQL, Power BI, and a lot more)_ 🔗 datacamp.pxf.io/vN1bDj (Affiliate) *COURSERA PYTHON* _(For beginners, Data Science, Data Analysis, AI, Cybersecurity and a lot more):_ 🔗 imp.i384100.net/k0Nk60 (Affiliate) *COURSERA WEB DEVELOPMENT* _(Full Stack, Front-End, Back-End, Web Design and a lot more):_ 🔗 imp.i384100.net/EKWxBW (Affiliate) Thank you for the support!❤ 🎥All my videos about Python: kzfaq.info/sun/PLs8qUrmRvaR0IT4IwJl-LSweAdACW-yLK
@gregoneill4391
@gregoneill4391 Жыл бұрын
do you have a video on validaing forms with data? with pysimple gui for example I have tried a few way but it wont properly validate for me
@FabioMusanni
@FabioMusanni Жыл бұрын
@@gregoneill4391 Hello 😊 No, at the moment I don't have videos about PySimpleGUI.
@tronicit
@tronicit 7 ай бұрын
I've been searching on how to select items from a list via input and the last part of your tutorial explained just that! Thanks very much 😁
@FabioMusanni
@FabioMusanni 7 ай бұрын
Glad to hear that you found what you were looking for 😉💪 And thank you so much for the comment! 😍
@grecellmarciales3341
@grecellmarciales3341 Жыл бұрын
Thank you for this, been running around in circles looking for the correct try..except.. for my float input for bmi calculation. Cant find clear explanation on the internet. This is veyr straightforward. Finally finished my assignment :)🤩☺☺ Subscribed🥰
@FabioMusanni
@FabioMusanni Жыл бұрын
Hello ☺️ Well done!! 🤩 I'm very happy that you could finish your assignment thanks to my video! 😍 🥳 Thank you for the subscription and welcome! 🥰
@python-cookie
@python-cookie Ай бұрын
🚀 Your video was incredibly helpful, Fabio! As a beginner developer, learning how to validate user inputs in Python seemed daunting, but your clear explanations and practical examples made it so much easier to grasp. Now I feel more confident in handling user inputs and ensuring the integrity of my programs. Thank you for sharing your expertise and making coding more accessible for everyone! 💪❤
@FabioMusanni
@FabioMusanni Ай бұрын
Thank you so so much for your kind words! Really appreciated! ❤😊💪
@yashrajdeo1108
@yashrajdeo1108 Жыл бұрын
Very useful. I could not find a good explanation about it anywhere.
@FabioMusanni
@FabioMusanni Жыл бұрын
Thank you for the comment! 🤗 I'm happy it was useful 💪😊
@ossy888888
@ossy888888 Жыл бұрын
Saved me on my exam! Cheers!
@FabioMusanni
@FabioMusanni Жыл бұрын
Hey Oskar! Glad to hear that, keep it up! 💪🔥
@izharchishty9089
@izharchishty9089 Ай бұрын
Thanks Brother Its Really Working
@FabioMusanni
@FabioMusanni Ай бұрын
Thank you for the comment! 💪😍
@JoeDonRB
@JoeDonRB Жыл бұрын
Fabio, can you Store strings ‘stone’, ‘paper’, ‘scissors’ in a list Ask the user to input their choice (validate) Pick a random item from the list to represent the computer Use if, elif commands to check who wins Display who won on the screen.
@FabioMusanni
@FabioMusanni Жыл бұрын
Hello 😊 Yes, you can use one of the methods I explain in the video for the validation, so that the user can only enter one of the 3 values and then you can pick a random item using the built-in random module, have a look at that. 😉🤗
@Meyaal
@Meyaal Жыл бұрын
Hello Fabio! This is amazing tutorial for my understandig! I really enjoed it😀 I am new at coding, how can I implement that on the hangman game the one that you created in the other video. I need to make the code to handle empty and invalid inputs from users without losing lifes if you understand what I mean. I need that specific for the hangman game that you have created because I don’t know how to implement that by my own. Plaese help me 🙏🏼
@FabioMusanni
@FabioMusanni Жыл бұрын
Hello Meya, thanks for the comment! 😊 Glad you enjoyed it, I hope you are learning a lot with my videos. In the Hangman game video at the line 33 and line 38 you get the "letter_user". Instead of just writing that, you need to write what I teach you in this video from min 11:25. You literally just have to write the "tuple_valid_chars" (13:31) at the beginning of the program where you have the list of all the variables (e.g. line 22), then you need to replace the code on line 33 and 38 with the code from line 60 through 68 in this video (13:44). Of course "user_input" should be named "letter_user" and make sure you keep the right indentation. I'm aware that you'll be writing the same lines of code twice, but to avoid that we would need to change the code a little bit and I can't go over it here. I hope this helps, you should have all the information you need to make it work, remember that it's really important to try, fail, try again, etc, especially at the beginning, it's how you get better. 💪 Of course keep watching my videos and experiment with what I teach you as well 😉 Bye 😊
@Meyaal
@Meyaal Жыл бұрын
@@FabioMusanni thanks a lot for your answer😀 I’ll try and do my best. Promise to watch all your videos and keep ask questions 😉 you are wonderfull person and I wish you all the best in your career path!
@FabioMusanni
@FabioMusanni Жыл бұрын
Thank you very much for your kind words! ☺️ I love it when people ask questions, because it means they really want to learn and are watching my videos seriously. So your questions/comments will always be appreciated. Bye ☺️🤓
@Meyaal
@Meyaal Жыл бұрын
@@FabioMusanni well I have a question about long line, I get too long line error for the tuple_valid_char, I tried to use backslash to break the line but i doesn’t work for me. Do you have other advice how I can do? 😃
@FabioMusanni
@FabioMusanni Жыл бұрын
That's really strange. Do you get that error when running the code in the terminal or is it an error that the code editor gives you? Which editor are you using?
@tazkiatahmid9754
@tazkiatahmid9754 Жыл бұрын
Why a question arrives when i do input?
@gamerbase5188
@gamerbase5188 2 ай бұрын
and what if i want a certain word ? how can i make it so everything but this word gets marked as Invalid?
@FabioMusanni
@FabioMusanni Ай бұрын
You can make a list of valid words, and check if the word entered is in that list, if so you go ahead, if not you ask for another word.
@quiztherapy6851
@quiztherapy6851 Жыл бұрын
when i entered break it throws an error that break can be used only within a loop. I checked everything seems ok. How to fix it?
@FabioMusanni
@FabioMusanni Жыл бұрын
Hello 😊 That error is definitely caused by a wrong indentation. The "break" needs to be under the while loop but also indented at least once. So you don't want something like this: while True: break But something like: while True: break
@e-stupidman
@e-stupidman 3 ай бұрын
Your method with the try...except loop does not work anymore. The program now crashes and says it cannot convert str to int. Is there a way to solve this problem?
@e-stupidman
@e-stupidman 3 ай бұрын
The only way I can avoid the problem is to slightly change the variable, e.g. "speed_Limit" to "speedLimit". May I know why this is happening?
@FabioMusanni
@FabioMusanni 3 ай бұрын
@@e-stupidman Hello, not sure what's causing this, changing the name of the variable doesn't affect what the program does, unless while changing the name you change something like the indentation or something else. Maybe check the indentation and make sure the code is in fact inside the try/except block.
@e-stupidman
@e-stupidman 3 ай бұрын
@@FabioMusanni Ok, I will check my program again. Thanks.
@jayl9744
@jayl9744 Жыл бұрын
I trying to add to this to a calculator i am making in python. But i having difficulty applying it to the (num 1 and num 2 user input portion if the user does enter a integer. it just returns an error, its not attached to the user input portion. How do i error check num 1 and num 2 for non interger values. i did use try and error but just had indentation issues. Thanks
@FabioMusanni
@FabioMusanni Жыл бұрын
Hello Jay. Thanks for the comment. 😊 The first example in the video does exactly what you are asking. You need to use the try except block with a while True loop if you want to keep asking the user until they enter two valid numbers. So, just write your two inputs (the one for num1 and the one for num2) in place of the "user_input" in the video and then try to convert both of them in the try block. If both of them are valid, then the program will continue and you can use those numbers below the try/except block, however, if at least one number is not valid, the program won't continue and the code in the except block will be run, so in the except block you can write what you want python to do if the user enters something wrong (in the video I just let them know with a message) 😊 Of course keep all the indentations in place, they are extremely important, and do things at steps, so don't write all of your code at once, just try this validation and if that works, then add your code so that you know if the problem is the validation or something else. I hope this helps 💪😉
@jayl9744
@jayl9744 Жыл бұрын
@@FabioMusanni Thank you that helped alot!! Writing a calculator program but trying to make it more functional with more variables the user can calculate. So i need a lot of ways to make sure the user can enter the right input and then end the program at anytime while its running.
@FabioMusanni
@FabioMusanni Жыл бұрын
No worries! 😉 Keep up the good work! 💪🔥
@ayushvispute4416
@ayushvispute4416 9 ай бұрын
I ain't getting ValueError as a seperate feature
Make Menus In Python with While True Loop | Choose an Option in Python
13:54
Fabio Musanni - Programming Channel
Рет қаралды 28 М.
КАРМАНЧИК 2 СЕЗОН 7 СЕРИЯ ФИНАЛ
21:37
Inter Production
Рет қаралды 385 М.
I’m just a kid 🥹🥰 LeoNata family #shorts
00:12
LeoNata Family
Рет қаралды 18 МЛН
когда повзрослела // EVA mash
00:40
EVA mash
Рет қаралды 2,8 МЛН
Tkinter - Entry - Validation
22:28
JobinPy
Рет қаралды 2,9 М.
How to Use Pandas With Pandera to Validate Your Data in Python
11:32
Python user input ⌨️
7:18
Bro Code
Рет қаралды 214 М.
5 Useful F-String Tricks In Python
10:02
Indently
Рет қаралды 269 М.
Python 101: Learn the 5 Must-Know Concepts
20:00
Tech With Tim
Рет қаралды 1,1 МЛН
Check If A Password Is Valid | Python Example
8:24
Portfolio Courses
Рет қаралды 4,4 М.
If __name__ == "__main__" for Python Developers
8:47
Python Simplified
Рет қаралды 383 М.
While loops in Python are easy ♾️
6:58
Bro Code
Рет қаралды 317 М.
Handling Form Data and Validation in Flask using PyCharm
8:33
Code And Course
Рет қаралды 2,5 М.
iPhone 12 socket cleaning #fixit
0:30
Tamar DB (mt)
Рет қаралды 54 МЛН
Урна с айфонами!
0:30
По ту сторону Гугла
Рет қаралды 7 МЛН