-1

I want program to print in one line but keep these two lines in code. How to do that ? I tryed to use comma but it's same

print(end1 + end2 + end3 + end4 + end5 + end6)

print(end7 + end8 + end9 + end10 + end11 + end12)
Erki M.
  • 5,022
  • 1
  • 48
  • 74
Pexlu
  • 13
  • 2
  • What's with the numbered variables? If this was a list you could `print(*end, sep='')` and be done with it. – jonrsharpe Jul 19 '15 at 14:24

2 Answers2

0

In Python 3, you now can specify and set the end param value to empty string in the first print statement.

print(end1 + end2 + end3 + end4 + end5 + end6, end="")
print(end7 + end8 + end9 + end10 + end11 + end12)
MCMastery
  • 3,099
  • 2
  • 20
  • 43
Avinash Raj
  • 172,303
  • 28
  • 230
  • 274
-1

This is essentially your question, though slightly more involved.

The end of the answer is that appending a comma outside the printed string will allow you to put multiple print statements on one line.

Ex):

for i in range(0,5):
    print i 

Will give you

0
1
2
3
4

But

for i in range(0,5):
    print i,

Will give you 0 1 2 3 4

In case that doesn't work for some reason, you can always use the \b backspace character to back out the linebreak the print whatever you want

Ex:

print("Hello")
print("\b World")
Community
  • 1
  • 1