I know similar questions have been asked and answered before like here: How do I check if a string is a number (float) in Python?
However, it does not provide the answer I'm looking for. What I'm trying to do is this:
def main():
    print "enter a number"
    choice = raw_input("> ")
    # At this point, I want to evaluate whether choice is a number.
    # I don't care if it's an int or float, I will accept either.
    # If it's a number (int or float), print "You have entered a number."
    # Else, print "That's not a number."
main()
Answers to most of the questions suggest using try..except, but this only allows me to evaluate int or floats exclusively, i.e
def is_number(s):
    try:
        float(choice)
        return True
    except ValueError:
        return False
If I use this code, int values will end up in the exception.
Other methods I've seen include str.isdigit. However, this returns True for int and false for float.
 
     
     
     
     
     
    