Python Forum
loop only prints last character.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
loop only prints last character.
#2
Try this

from datetime import datetime
import time
 
 
def get_time():
    now = datetime.now()
    current_time = now.strftime("%H:%M")
    return current_time
 
while True:
    print(get_time(), end="\r") # Only prints last character of get_time().
    time.sleep(60)
I welcome all feedback.
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags


Reply


Messages In This Thread
loop only prints last character. - by mcmxl22 - Feb-17-2020, 02:04 AM
RE: loop only prints last character. - by menator01 - Feb-17-2020, 02:36 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  zfill prints extra et the end of a var tester_V 4 899 Mar-24-2023, 06:59 PM
Last Post: tester_V
  variable prints without being declared. ClockPillow 2 1,808 Jul-11-2021, 12:13 AM
Last Post: ClockPillow
  [solved] unexpected character after line continuation character paul18fr 4 3,396 Jun-22-2021, 03:22 PM
Last Post: deanhystad
  Output prints Account.id at the end? LastStopDEVS 5 2,765 Dec-19-2020, 05:59 AM
Last Post: buran
  Try/Exept prints only ones tester_V 11 3,873 Nov-03-2020, 02:38 AM
Last Post: tester_V
  SyntaxError: unexpected character after line continuation character siteshkumar 2 3,172 Jul-13-2020, 07:05 PM
Last Post: snippsat
  how can i handle "expected a character " type error , when I input no character vivekagrey 2 2,735 Jan-05-2020, 11:50 AM
Last Post: vivekagrey
  For loop prints strane values? colt 2 2,191 Sep-22-2019, 02:01 AM
Last Post: ichabod801
  Replace changing string including uppercase character with lowercase character silfer 11 6,192 Mar-25-2019, 12:54 PM
Last Post: silfer
  can you understand why this code prints None? arcbal 2 2,749 Mar-13-2019, 02:57 AM
Last Post: arcbal

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020