1

In the code below, the diamond characters (\4) are not printed immediately but after the loop is completed. Any ideas why?

from os import system from time import sleep def load(): system('cls') i = 0 sleep(1) print("\n\n\n\n\n\n\n\n\n\n\n\t\t\t Loading ", end=' ') for i in range(6): sleep(1) print("\4", end=' ') sleep(2) load() 
1
  • Could not reproduce in Python 2 (using from __future__ import print_function) Commented Jul 6, 2017 at 6:56

1 Answer 1

1

The printing is working in Python IDLE for me. In Windows cmd it does not. Removing the end=' ' solves this, but then each diamond gets printed on a new line.

Depending on your OS you have to change the line ending. Check this page for more info on that: Python print on same line


This is working on Windows:

from os import system from time import sleep import sys def load(): system('cls') i = 0 sleep(1) sys.stdout.write("\n\n\n\n\n\n\n\n\n\n\n\t\t\t Loading ") for i in range(6): sleep(1) sys.stdout.write("\4") sys.stdout.flush() sleep(2) load() 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.