1

I have a variable score wich increases over time I but would like to print only the integer ones. like 1.0, 2.0, 3.0 et cetera.

    score += 0.5
    if score.is_integer:
        print(score)

But actually every score is printed.

0.5
1.0
1.5
2.0
2.5
3.0
3.5
4.0
4.5
5.0
5.5
6.0
6.5
7.0
7.5
8.0
8.5
9.0
9.5

What do I miss here?

Din
  • 33
  • 6

1 Answers1

1
if int(score) == score:

this should work fine or just follow the comment by @Robin Zigmond ie.,

if score.is_integer():
Irfan wani
  • 4,084
  • 2
  • 19
  • 34