Reputation: 43
I'm new to programming and I have a question as if there's a way to get one line output for two 'print' lines.
Ex:
end1 = ("A")
end2 = ("B")
end3 = ("C")
end4 = ("D")
print (end1 + end2,)
print (end3 + end4)
Response currently is
AB
CD
Is there a way to get response in one line with two 'print' input lines?
AB CD
Upvotes: 0
Views: 360
Reputation: 2144
print(end1 + end2 + ' ' + end3 + end4)
OR
print('{:s}{:s} {:s}{:s}'.format('A','B','C','D'))
OR
print(end1 + end2, end=" ")
print(end3 + end4)
If you don't want the last line to output a newline, you can add end=""
to it. In general, the default end
argument of print
is \n
but you can change it to whatever you want.
Upvotes: 0
Reputation: 1673
default end value is \n
, You can define your own end
Try this
print (end1 + end2,end="")
print (end3 + end4,end="")
Upvotes: 2