fix(problem-02.py): realized solution was incorrect
This commit is contained in:
@@ -1,11 +1,3 @@
|
|||||||
# Problem 2: Write a Python program that prompts the user to input an integer and raises a ValueError exception if the
|
# 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.
|
# input is not a valid integer.
|
||||||
|
|
||||||
try:
|
|
||||||
# Prompt user to enter an integer
|
|
||||||
integer = int(input("Enter any integer: "))
|
|
||||||
# Print confirmation message
|
|
||||||
print(f"Correct, {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.")
|
|
||||||
Reference in New Issue
Block a user