0 votes
1 view
in Python by (47.8k points)

In python, if I say

print 'h'

I get the letter h and a newline. If I say

print 'h',

I get the letter h and no newline. If I say

print 'h', print 'm',

I get the letter h, space, and the letter m. How can I prevent Python from printing the space?

The print statements are different iterations of the same loop so I can't just use the + operator.

1 Answer

0 votes
by (107k points)

To keep Python print from adding newlines or spaces you can use below-mentioned code:-

sys.stdout.write('h') 

sys.stdout.write('m')

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...