fix(problem-02.py): completed problem-02
This commit is contained in:
@@ -1,3 +1,10 @@
|
|||||||
# 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.
|
||||||
|
|
||||||
|
# Define the function int_check to check if user input is an integer
|
||||||
|
def int_check(x):
|
||||||
|
# Cast user input as integer, throws ValueError if not
|
||||||
|
x = int(x)
|
||||||
|
|
||||||
|
# Call the function, prompting the user to input an integer
|
||||||
|
int_check(x = input('Enter an integer: '))
|
||||||
Reference in New Issue
Block a user