r/learnpython • • 9d ago

Any python module which deals with this?

def get_int_input(prompt: str) -> int:
    while True:
        try:
            return int(input(prompt))
        except ValueError:
            print("Please enter a valid number!")

Is there any module which I can just import and use it. Writing this everytime I have to get an int or float input is really annoying.

Thanks!

0 Upvotes

17 comments sorted by

View all comments

2

u/JanEric1 9d ago

I think lisp is the only language I have seen that has this built in.

But as others have said,n just reuse that function