new print on the same line substitution python 3 1

new print on the same line substitution python 3

for x in range(10):
    print('\r H M S 0 0 {}'.format(x), end='')
    time.sleep(1)

Here is what the above code is Doing:
1. We’re using a for loop to iterate through the numbers 0-9.
2. We’re printing the string ‘H M S 0 0’ and then the number x.
3. We’re using the end=” argument to tell Python to print the string on the same line.
4. We’re using the time.sleep() function to pause the program for 1 second.

Similar Posts