I am trying to validate a user's input. I only want the user to be able to enter a positive or negative integer. All other inputs (i.e. anything with letters) should be rejected
I have the code below at the minute, however I am getting an error. I'm assuming it has to do with the data types but am unsure how to fix this.
import re
number =input("Please enter a number: ")
number=int(number)
while not re.match("^[0-9 \-]+$", number):
print ("Error! Make sure you only use numbers")
number = input("Please enter a number: ")
print("You picked number "+ number)