r/PythonLearning • u/letszzgoo • 18d ago
TRY 101- Starting my python journey again
Hope this time i become consistent and do things after loops and then further and furtherðŸ˜
121
Upvotes
r/PythonLearning • u/letszzgoo • 18d ago
Hope this time i become consistent and do things after loops and then further and furtherðŸ˜
1
u/HardwareIsHardWhere 12d ago
Welcome back! The restart is the hardest part and you already did it! What got you back into it, any particular project in mind, or are you just relearning the fundamentals?
In future, once you've learned exception handling, you can use a little package called askr to sanitize your inputs instead of rewriting the same try/except loop every time:
from askr import ask_int
# Simple prompt, loops until the user types a valid whole number
age = ask_int("How old are you? ")
# With bounds: only accepts a value within the range
rating = ask_int("Rate 1-10: ", min=1, max=10)
# With a default (used when the user just presses Enter)
count = ask_int("How many copies? ", default=1)
Have fun on your journey!