1

I am learning now how to make my program distinguish two types of input in one function... I know its possible but how can I actually do it ;-; Heres abit of my code:

def alphanumeric_input_detection(base_input):
    if (type(base_input)==str):
        return (print("you've written it wrong you dumm dumm"))
    else:
        return(print("thats correct input"))

base_input=input("please write a number")

alphanumeric_input_detection(base_input)
  • for first I was like "Hey letters are string and numbers are just ints or floats" but becouse of this I've realised that every input is count as a string – Shazbot Polska Nov 03 '18 at 18:28

1 Answers1

1

You can use the isnumeric() function. It returns True if a string object is numeric.

s = '1'
print(s.isnumeric())
[Output] = True
Franndy Abreu
  • 186
  • 2
  • 12