Using the print command in Python3

G

Grady Knotts

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?
 
S

Steven D'Aprano

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?


print("Hello", end=' ')
print("world")


outputs:

Hello world
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Python3 string slicing 2
Pyglet on Python3.x, problems 5
Command Line Arguments 0
sys.stdout and Python3 0
Print with command-line arguments 0
Why Python3 12
[python3] 6
Finding Relative Maxima in Python3 1

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top