Files
cybr108/lab-02/problem-02.py
T
2026-09-12 21:03:22 -04:00

11 lines
446 B
Python

# Problem 2: Write a Python program that prompts the user to input an integer and raises a ValueError exception if the
# input is not a valid integer.
try:
# Prompt user to enter an integer
integer = int(input("Enter any integer: "))
# Print confirmation message
print(f"{integer} is an integer.")
except ValueError:
# If input is a non-integer, explain and prompt for re-entry
print("That is not an integer, try again.")