0

I am taking in intro CS course and am playing around with some of my old code from an early lab. The program asks for four separate inputs from the user and will then spit out a graph according to the four inputs. I'm trying to get it where if the user does not enter a number then it asks for them to try again and prompt for another input. I've tried things like: (if x != int:) and (if x =\= int:) but nothing has worked for me.

1 Answers1

-4

You could do something like this:

userInput = 0
while True:
  try:
     userInput = int(input("Enter an integer: "))       
  except ValueError:
     print("Not an integer!")
     continue
 else:
     print("Yay an integer!")
     break 
bhazero025
  • 337
  • 4
  • 15