Reputation: 13
When I print a strings character one by one in a line, space occur automatic. between them!!
import time
a="mayank"
for z in a:
time.sleep(0.1)
print z,
m a y a n k
But I want to print them without spaces between them!! Like:-
mayank
In python2.7
Upvotes: 0
Views: 174
Reputation: 119
Try:
import time
a="mayank"
for z in a:
time.sleep(0.1)
print (z, end="")
Upvotes: 0
Reputation: 363213
You can do this:
from __future__ import print_function
print(z, end='')
Another option:
import sys
sys.stdout.write(z)
If your Python is running with buffered io, you might not see any output until a newline character is written. In that case, you can force writing the output immediately by adding a call to sys.stdout.flush()
.
Upvotes: 5