I'm relatively new to program and I'm creating a credit calculator program for assignment. Now, in order to validate the inputs, I was asked to include a function in the program that will only allow integers for the user to input. If the input is a letter, they should get an error, asking them to try again. Now the problem with my program is that it will move on to the next question after asking the user to try again. How can I make sure the program asks the same question again after the wrong value is entered until the user inputs the right type of input?
passCR = input("Enter your pass credits")
try:
passCR = int(passCR)
except ValueError:
print("Not an integer! Try again.")
This will help:
while True:
passCR = input("Enter your pass credits")
if passCR.isdigit():
passCR = int(passCR)
break
else:
print("Not an integer Value")