Oct-03-2018, 02:58 PM
This isn't a required part of a program, but I wanted to learn how to do this so I don't break my program everytime I input an incorrect value. I tried using
such as testing if a is a number where a=input("Type a number here: ")
currently, if the input is -1 I have no way of checking if that's a number.
def is_number(s): try: float(s) return True except ValueError: return Falsebut this code does not work for negative numbers. How could I test if a user input is ANY number?
such as testing if a is a number where a=input("Type a number here: ")
currently, if the input is -1 I have no way of checking if that's a number.