This question already has an answer here:
- How to determine the variable type in Python? 12 answers
- Determine the type of a Python object 8 answers
Im trying to write a prime number checker in python and I can't write an if statement where if will run code it the result is an integer or not. I think that it should look like this.
x = 2
if result is int:
print("something")
elif result is float:
print("something else")
else:
print("something final")
or this:
x = 2
if result == int:
print("something")
elif result == float:
print("something else")
else:
print("something final")
Both of these bits of code print the statements that are in the else statements. Can anyone help me with the code that will actually work?
Aucun commentaire:
Enregistrer un commentaire