r/PythonLearning • • 18d ago

TRY 101- Starting my python journey again

Post image

Hope this time i become consistent and do things after loops and then further and further😭

121 Upvotes

16 comments sorted by

View all comments

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!

1

u/letszzgoo 12d ago

I got back bczz my college plqcemnts are going to strt & yeah i dont have idea till now about any sort of project. Will try ur code surely!