Reputation: 21
I have a nexted for loop like below:
for N1 in range(1, 96):
for N2 in range(N1 + 1, 97):
for N3 in range(N2 + 1, 98):
for N4 in range(N3 + 1, 99):
for N5 in range(N4 + 1, 100):
remaining coding logic
I would like to have a process progress indicator prompt (stationary line) to show the nexted for loops increment like
print("N1:", N1, "N2:", N2...)
All my attempts (like the print above or sys.stdout.write/sys.stdout.flush
) have created scrolling process progress indicator prompt, what does not look really pretty.
Thank you
I have tried progress, but doesn't work very well in the nested loop:
bar1 = Bar('Processing B1', max=20)
for i in range(20):
bar2 = Bar('Processing B2', max=20)
for x in range(20):
bar2.next()
bar2.finish()
bar1.next()
bar1.finish()
Processing B2 |################################| 20/20
Processing B2 |################################| 20/20
Processing B2 |################################| 20/20
Processing B2 |################################| 20/20
Processing B2 |################################| 20/20
Processing B2 |################################| 20/20
Processing B2 |################################| 20/20
Processing B2 |################################| 20/20
Processing B2 |################################| 20/20
Processing B2 |################################| 20/20
Processing B2 |################################| 20/20
Processing B2 |################################| 20/20
Processing B2 |################################| 20/20
Processing B2 |################################| 20/20
Processing B2 |################################| 20/20
Processing B2 |################################| 20/20
Processing B2 |################################| 20/20
Processing B2 |################################| 20/20
Processing B2 |################################| 20/20
Processing B2 |################################| 20/20
Processing B1 |################################| 20/20
Upvotes: 0
Views: 55
Reputation: 43495
Use the following print statement;
print("\033[1G\033[0KN1:", N1, "N2:", N2, end='')
The stuff at the beginning are ANSI escape codes.
\033[1G
means "move the cursor to column 1".\033[0K
means "clear to the end of the line".Upvotes: 1