Tag Archives: Learn python

In Python, print() prints to remove line breaks

python print() prints, the default is a newline.
for example:

print('abc')
pirnt('xyz')

gives us

abc
xyz

what do I do if I want to get , abcxyz, which is to print two lines and put them in one line.
can be used with the code:

print('abc',end='')
print('xyz')

so that the printed result does not have a line break:
abcxyz

before I saw someone on the Internet write this:

print('abc'),
print('xyz')

is comma separated, and this python3 is no longer valid. Python2 works fine. But there’s a space in between, and in python2 the printed result is: ABC xyz