+ 1

New line

I want to know if printing on a new line is a property of for loop ? what if we want to print these items one after the other in a single line?

1st Feb 2017, 10:01 AM
Hamid - avatar
1 Answer
+ 2
In Python 3.x you can add a named parameter at argument: print('what I want whithout line break ending', end='') You can make it work in Python 2.x ( else you can 'import sys' and use 'sys.stdout.write()' function, but need to call 'sys.stdout.flush()' ) by importing print function from Python3: from __future__ import print_function If you are having troubles with buffering, you can force the flush: print('some string', end='', flush=True)
1st Feb 2017, 10:26 AM
visph - avatar