0

code below is a part of web scraper and it prints page numbers as page number.0

How to remove that .0 and only print page numbers?

for page in range(0, 1040, 20):
    print(f'===== Page {(page/20)+1} =====')

# print result  ===== Page 1.0 =====
2752353
  • 17
  • 5

1 Answers1

0

Dividing automatically makes the result turn into a Float type even if "page" was set as an int() type prior. Add the int() method in print to convert it into an integer.

print(f'===== Page {int((page/20)+1)} =====')