Skip to main content

easy_int_input

Project description

Valid Integer Checker This Python script contains two functions: valid_int() and get_int(). The valid_int() function takes a string as input and checks to see if it is a valid integer. The get_int() function prompts the user for input, and only accepts valid integers as input.

Functionality The valid_int() function first checks to see if the input string is empty. If it is, the function returns False. Otherwise, the function checks to see if the first character is a negative sign. If it is, the negative sign is removed and the rest of the string is checked for validity.

The get_int() function prompts the user for input and uses the valid_int() function to check the input for validity. If the input is not a valid integer, the user is prompted to try again. Once a valid integer is entered, it is returned as an int type.

Usage To use these functions in your own code, simply import them using the following statement:

from main.py import valid_int, get_int Then, you can use the valid_int() and get_int() functions as needed. For example:

x = get_int("Enter a valid integer: ") print(f"You entered: {x}")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

get_int-1.0.0.tar.gz (14.8 kB view hashes)

Uploaded Source

Built Distribution

get_int-1.0.0-py3-none-any.whl (14.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page