Skip to content
Advertisement

I have a problem with if statement and numbers

my problem is I want to make the elif statement work on numbers only but the elif statement work on any datatype, is there any way i can separate the numbers in string type from the other data types

The Code

JavaScript

OutPut

JavaScript

Advertisement

Answer

You can use and for this:

JavaScript

Note that you can use in to check if a key in the dictionary, so you don’t need to call .keys() or convert it to a list for that.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement