0

Here's an example on what I'm trying to achieve :

print("Hi!")
print("Hello!")
>> Hi! Hello!

Whats really happening :

print("Hi!")
print("Hello!")
>> Hi!
>> Hello!

I've tried stuff like sep=" " and print("Hi!"), but those didn't work.

Please don't mark this as duplicate since all the answers for this question don't work for my situation.

https://pastebin.com/57xyqb8C : For my full code.

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
  • 1
    `print('Hi!', end='')` This removes the new line at the end of the string. – JANO Feb 06 '22 at 14:43
  • You've not clearly shown that the answers in the duplicate don't work and the answers below are all the same, so I'm closing this. `sep` is only used when there are multiple arguments to the print function – OneCricketeer Feb 06 '22 at 14:51

2 Answers2

3

I think this solves your problem:

print("Hi!", end='')
print("Hello!")

Hi! Hello!
redystum
  • 352
  • 3
  • 10
3

The end keyword is used for this in python. You could have any value for it:

print("Hi!", end=' ')
print("Hello!")

>>> Hi! Hello!

print("Hi!", end = ' This is a string \n')
print("Hello!")

>>> Hi! This is a string 
>>> Hello!
Codeman
  • 477
  • 3
  • 13