Using the print command in Python3

Navkirat Singh navkirats at
Tue Aug 10 07:59:58 CEST 2010

On 10-Aug-2010, at 11:04 AM, Benjamin Kaplan wrote:

> On Mon, Aug 9, 2010 at 10:17 PM, Grady Knotts <gradyknotts at> wrote:
>> In earlier versions of Python I can do:
>>        print 'A',
>>        print 'B'
>> to print everything on the same line: 'A B'
>> But I don't know how to do this with Python3
>> I've been trying things like:
>>        print('A',)
>>        print('B')
>> and it prints two different lines.
>> So, do I get two different print statements to output on the same line?
>>>> help(print)
> Help on built-in function print in module builtins:
> print(...)
>    print(value, ..., sep=' ', end='\n', file=sys.stdout)
>    Prints the values to a stream, or to sys.stdout by default.
>    Optional keyword arguments:
>    file: a file-like object (stream); defaults to the current sys.stdout.
>    sep:  string inserted between values, default a space.
>    end:  string appended after the last value, default a newline.
> -- 

One method of doing this:
	Use the join method of the string:

		print(    "".join(    [  'A' , '<space> B'  ]   )

	This will give you :


I have used extra spaces just for clarity. Hope this helps !


More information about the Python-list mailing list