I am very very new to programming, and this is my first day using Python.
I want to check to see if an input is of type 'int' and to proceed with my program if the user has entered an 'int', otherwise to print some error message, followed by a prompt to the user to try again.
What I have:
user_in = input('Input an integer value') if type(user_in) == int: a = user_in else:
I'm really not sure what to do here, or if its even possible to achieve this way, hence the blank line after 'else:'! I tried it with a while loop with try and excepts such as this:
while True: try: user_in = int(input('Enter an integer value')) a = user_in except: print('Invalid input, please try again')
Which works good for the exception case (because of the while True essentially acting infinitely), but of course, does not move on to the next part of the code in the case where an integer has successfully been inputted.