import time for i in range(0, 101, 2): time.sleep(0.1) NUM = I // 2 # floor addition, i.e. not taking the smallest integer greater than / the (// 2. 3 =. 1, = 2. 4. 9 //, // 2 = -7 -4) s_str = ' \ R & lt {} %: {} \ n- ' .format (I, ' * ' * NUM) IF I == 100 the else ' \ R & lt% {}: {} ' .format (I, ' * ' * NUM) # \ R & lt expressed per times the cursor will move to the first line, non-breaking print (s_str, End = '' , the flush = True) = # End '' each designated print terminator is empty, the default is the \ n is newline
Progressive display until 100%: ******************************************* *******