-2

How (in python) can I change numbers to be going up. For example, 1 (time.sleep(0.05)) then it changes to two, and so on. But there will be text already above it, so you can't use a simple os.system('clear')

So like this:

print("how much money do you want to make?")< 'number going up without deleting the "how much money" part'

Fortran95
  • 11
  • 2

3 Answers3

1

Like this:

import sys
import time

for i in range(10):
    time.sleep(0.3)
    sys.stdout.write("\rDoing thing %i" % i)
    sys.stdout.flush()

Edit: This was taken from Replace console output in Python

John3331
  • 46
  • 3
1

I am assuming that you want it to sleep for 1 second the first time, 2 seconds for the second time, and so on. You could create a function.

counter = 0
def my_function():
  global counter
  sleep(counter)
  counter = counter + 1
for i in range(3):
     my_function()

This is an example of what you can do.Change it to meet your needs.

0

The question is very unclear, but maybe you mean the following:

import time
for item in [0.05,2,3]:
    time.sleep(item)

and

number = 3
print("how much money do you want to make? {}".format(number))
Uwe.Schneider
  • 1,112
  • 1
  • 15
  • 28