S
Scott Novinger
Hello.
I've written a program for my kids to calculate arc length. I want to include some error testing for value types entered that are something other than integer values.
My goal is to make sure that the value entered for the radius is an integer value.
How could I rewrite this code to make sure I accomplish my goal of getting an integer value entered? I know the construct is not correct. I'm just learning how to program.
# Create the variable for radius, "radius".
print('Please enter the circle radius and press ENTER:')
radius = input()
# Check to make sure the entered value is an integer.
if type(radius) != type(int):
print('You must enter an integer value.')
print('Please enter the circle radius and press ENTER:')
radius = input()
else:
print('The radius you entered is: ' + radius)
radius = int(radius)
Thanks for your help. I'm using Python v3.2 for windows.
Scott
I've written a program for my kids to calculate arc length. I want to include some error testing for value types entered that are something other than integer values.
My goal is to make sure that the value entered for the radius is an integer value.
How could I rewrite this code to make sure I accomplish my goal of getting an integer value entered? I know the construct is not correct. I'm just learning how to program.
# Create the variable for radius, "radius".
print('Please enter the circle radius and press ENTER:')
radius = input()
# Check to make sure the entered value is an integer.
if type(radius) != type(int):
print('You must enter an integer value.')
print('Please enter the circle radius and press ENTER:')
radius = input()
else:
print('The radius you entered is: ' + radius)
radius = int(radius)
Thanks for your help. I'm using Python v3.2 for windows.
Scott