import sys
import time

index = 0
for url_dict in range(100):
    time.sleep(0.1)
    index += 1

    percentual = "%.2f%%" % index
    sys.stdout.write('\r[{0}{1}] {2}'.format('#' * index,
                                             ' ' * (100-index),
                                           percentual))
    sys.stdout.flush()
    
print("")

import sys
import time
import math

n_messages = 650

for index, url_dict in enumerate(range(n_messages)):
    index += 1
    time.sleep(0.01)
    
    progress_index = math.floor(index/n_messages*100)

    percentual = "%.2f%%" % progress_index
    sys.stdout.write('\r[{0}{1}] {2}'.format('#' * progress_index,
                                              ' ' * (100-progress_index),
                                            percentual))
    sys.stdout.flush()
    
print("")

Make it work properly with every number
Make it work properly with every number
  import sys
  import time
+ import math
  
- index = 0
- for url_dict in range(100):
-     time.sleep(0.1)
+ n_messages = 650
+ 
+ for index, url_dict in enumerate(range(n_messages)):
      index += 1
+     time.sleep(0.01)
+     
+     progress_index = math.floor(index/n_messages*100)
  
-     percentual = "%.2f%%" % index
+     percentual = "%.2f%%" % progress_index
-     sys.stdout.write('\r[{0}{1}] {2}'.format('#' * index,
+     sys.stdout.write('\r[{0}{1}] {2}'.format('#' * progress_index,
-                                              ' ' * (100-index),
+                                               ' ' * (100-progress_index),
-                                            percentual))
+                                             percentual))
      sys.stdout.flush()
      
  print("")
  
Make it work properly with every number
## Code Before:
import sys
import time

index = 0
for url_dict in range(100):
    time.sleep(0.1)
    index += 1

    percentual = "%.2f%%" % index
    sys.stdout.write('\r[{0}{1}] {2}'.format('#' * index,
                                             ' ' * (100-index),
                                           percentual))
    sys.stdout.flush()
    
print("")

## Instruction:
Make it work properly with every number
## Code After:
import sys
import time
import math

n_messages = 650

for index, url_dict in enumerate(range(n_messages)):
    index += 1
    time.sleep(0.01)
    
    progress_index = math.floor(index/n_messages*100)

    percentual = "%.2f%%" % progress_index
    sys.stdout.write('\r[{0}{1}] {2}'.format('#' * progress_index,
                                              ' ' * (100-progress_index),
                                            percentual))
    sys.stdout.flush()
    
print("")
