Because typing int(input()) everywhere is a rite of passage we'd rather skip.
⚠️ Disclaimer: This started as a joke among friends after someone accidentally typed intput. Don't take it too seriously.
IntputLib is a tiny Python library designed to save you from the repetitive strain of capturing numerical input from users. It handles the boring try-except loops so you can focus on the fun parts of your code.
No more writing this masterpiece of error-handling over and over again:
while True:
try:
x = int(input("Enter a number: "))
break
except ValueError:
print("Invalid input. Please enter a number.")Just a simple pip install away (if only everything in life were this easy):
pip install intputlibHere’s how you can reclaim your time and sanity.
Use intput() as a smarter, more patient version of int(input()).
from intputlib import intput
age = intput("Enter your age (or fake it, we won't judge): ")
print(f"You are {age} years old!")Tired of the generic "invalid input"? Give your users a custom message.
from intputlib import intput
score = intput("Enter your score: ", error_msg="Come on, numbers only!")
print(f"Your score: {score}")Keep your users in line by specifying a minimum and maximum value.
from intputlib import intput_range
level = intput_range("Choose a level (1-10): ", min_val=1, max_val=10)
print(f"You selected level {level}!")You can also customize the error message for out-of-range inputs.
difficulty = intput_range(
"Select difficulty (1-5): ",
min_val=1,
max_val=5,
error_msg="Oops! Only numbers between 1 and 5 are allowed."
)
print(f"Difficulty set to {difficulty}")For when you need those decimal points.
from intputlib import floatput
height = floatput("Enter your height in meters (e.g., 1.75): ")
print(f"Your height: {height} m")- Simplified Input: Read integers and floats with a single, clean function call.
- Hassle-Free Validation: Automatically handles
ValueErrorand keeps asking until a valid number is entered. - Range Enforcement: Easily restrict integer inputs to a specified range.
- Customizable Prompts: Tailor your input prompts and error messages.
- No More Crashes: Saves your scripts from the dreaded
ValueErrorwhen a user types "abc" instead of "123".
Because life is too short to write the same validation loop for the hundredth time. Let intput() handle the nagging for you, so you can get back to building amazing things.
MIT License. Because sharing is caring.