-1

I wanted my program to check if the code was a valid number A valid number in my case is :123, 43.76, 89, 100000, 78765.987 etc. infinite NoN_valid_number: 123abc, 7.9.8, afadf, *&^dadsf ... etc

  • How do I implent this in python
y = 11SS # it doesnt let me input this value and I get an error

if type(y) == int or float:
    print('valid')
else: 
    print('non valid')
Alex
  • 6,610
  • 3
  • 20
  • 38
JAKY
  • 7
  • 2

1 Answers1

0

The reason you are getting an error is that you are effectively setting y to a string without putting the quotes around it. Try y = "11SS"

3ddavies
  • 546
  • 2
  • 19