r/PythonLearning • • Sep 17 '26

Discussion Recently started learning python from BroCode and I’m 1 and a half days in.(around 5 hours of actual learning) and when he said to do an input validation project I did it myself before looking at his example. Which one is better? Wanna see if I should use his style for input validation or not

Left one is mine and right one is BroCode’s

169 Upvotes

41 comments sorted by

View all comments

6

u/Electrical_Toe8997 Sep 17 '26

The one on the right is more concise. I'd prefer to have the rule checks independently, so the user will know if the username fails multiple checks. I hate the way the check for spaces is implemented, I'd have gone with if " " in username:

2

u/abt-dabest Sep 17 '26

I didnt know you can do it like that! That seems much better for checking for a specific character! I will definitely use this from now on, thanks for the tip!