Johnny Lee wrote: > Roy Smith wrote: > >>For closer control over output, use the write() function. You want >>something like: >> >>import sys >>for i in range(3): >> sys.stdout.write (str(i)) > > > here is the output of my machine: > > >>> import sys > >>> for i in range(3): > ... sys.stdout.write(str(i)) > ... > 012>>> > > Why the prompt followed after the output? Maybe it's not as expected. Because, unlike print, sys.stdout.write() just sends the raw bytes directly to the output without special formatting, extra characters (such as the newline print adds for you), or other interference. Add the newline yourself after the loop to fix this: sys.stdout.write('\n') -Peter
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4