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 details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

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

Uploaded Python 3

File details

Details for the file get_int-1.0.0.tar.gz.

File metadata

  • Download URL: get_int-1.0.0.tar.gz
  • Upload date:
  • Size: 14.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.5

File hashes

Hashes for get_int-1.0.0.tar.gz
Algorithm Hash digest
SHA256 1bf4f4019ee23fae53d79a55058d81f53c0e4ee7ca79931199c3cb098c6a70bb
MD5 e7485e80ce5ef367758308730c11272a
BLAKE2b-256 1f8304dbe59e5c4b55a7f2a63ad2732022d183feedb0d5937e4428b2ccc7a4cf

See more details on using hashes here.

File details

Details for the file get_int-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: get_int-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 14.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.5

File hashes

Hashes for get_int-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 82406263b2e2bc18c6eb69f0e0f8535b58a290641ae67d92c56e0b886306dc03
MD5 0126ec68247d0cebfa323024819575c7
BLAKE2b-256 b07be7c10405fbf1d5edcf0ebbfe3ea88e012e4654c3c82e6561b2bd40c4c1e2

See more details on using hashes here.

Supported by

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