I have the following code in Python 3:
events_count = len(events)
for i, e in enumerate(events):
finished = 100*(i/events_count)
if finished % 10 == 0:
logger.info('Finished processing {} % of all events'.format(int(finished)))
In the current case events_count = 133805
and it's printing only 20%, 40%
, etc. but not 10%, 20%, 30%
. How can I achieve that? I tried rounding: finished = 100*round((i/events_count), (len(str(events_count))))
but it doesn't work. I tried also subtracting one from the length of precision but it starts printing some percentages twice.
I am not interested in progress bars, just in the correct computation here.