How can I make my blinking string also change values? (Python 3.5) -
i have following piece of code in python 3.5:
def blink(char): while 1: print (char, end = '\r') time.sleep(0.5) print (' ' * 50, end = '\r') time.sleep(0.5)
i using function make string blink specific time
the problem when use in code below doesn't have desired effect:
while true: time.sleep(0.5) seconds += 1 if seconds == 60: minutes += 1 seconds = 0 if minutes == 60: hours += 1 minutes = 0 if hours == 24: days += 1 hours = 0 blink ('days: %s, hours: %s, minutes: %s, seconds: %s' % (days, hours, minutes, seconds))
i'm using piece of code 'simulate' time. problem output looks this:
days: 0, hours: 0, minutes: 0, seconds: 1
this keeps on blinking on same line want to, problem output doesn't increase.
e.g days: 0, hours: 0, minutes: 0, seconds: 2 etc.
the blink(char)
function not end, while true
loop stuck in first cycle.
try removing while loop blink function make blink once:
def blink(char): print(char, end = '\r') time.sleep(0.5) print(' ' * 50, end = '\r') time.sleep(0.5)
(or create separate blink_once
function.)
Comments
Post a Comment