Ask coding questions

← Back to all posts
How do I classify an integer in an elif statement?
SharayhB

LINES 41 TO 47.
I want to say that if the input is a number, then print 'Its a number, not a sport'. I am new to python so don't judge. Click on files to actually open the program. The first one is just a command telling replit to run a specific file. LOOK AT LINES 41 TO 47.

Voters
SharayhB
Comments
hotnewtop
NFadhlurrahman
SharayhB

@NFadhlurrahman That works perfectly fine, but I'm trying to create like a range, meaning that that I want the numbers to be from 0 to a like 1 000 000 without having to write the numbers down.

Kai_Justice

@SharayhB

It's the same outcome even with the range to a million included (other than taking longer), all possible numbers are already included in the previous answer.

Or maybe you're talking about something like this?

deadartz

Rather than using a subset; you can just use the isnumeric() function.

Simple way to replace is just changing the current line to elif (prompt.isnumeric()):. One caveat of this method is that it will only return True if the entire string is a number, otherwise it will return False