-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
  • 5,950
  • 3
  • 18
  • 36
JAKY
  • 7
  • 1
  • "I get an error"—please read [ask]. "An error" is not helpful. The _specific, exact, complete_ error _would_ be helpful. Please read [ask]. – Chris Oct 18 '21 at 22:58
  • ...do you expect `11SS` to be valid for some reason? How is that a valid number? – Chris Oct 18 '21 at 22:59

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
  • 508
  • 2
  • 18