I'm very new to python but I was wondering if there is a way to check if a float is an integer e.g if the float = 9.0
Asked
Active
Viewed 44 times
1 Answers
0
Yes there is.
x = 9.0
if x.is_integer():
print("It's an int!")
else:
print("It's not what we wanted.")

JimmyCarlos
- 1,934
- 1
- 10
- 24
-
do I put what I want to happen in the brackets? `if x.is_integer()` – Gyro161 Aug 06 '20 at 10:54
-
Yes, I've updated the answer for you. :-) – JimmyCarlos Aug 06 '20 at 12:17