Print() with no space in writing between two different text strings,


this is a beginner question.

word_1 = print("Please give word: ")
word_2 = print("Please give another word: ")
print(“The combined word is ‘“word_1 word_2”’”)

[input: word_1 = one, word = two]
The print should be “The combined word is ‘onetwo’”

However, it shows syntax error.

I only know to how to write this with a space:
print(“The combined word is ‘“word_1, word_2”’”)
“The combined word is ‘one two’”

How could I do this?

Thank you in advance.

Please wrap code in triple backticks to preserve the formatting:

if True:
    print(''Hello world!')

The simplest method is probably using f-strings:

print(f"The combined word is {word_1}{word_2}")

Incidentally, when asking for a word, you should use input because print only prints.

1 Like

Or print(word1, word2, sep=''). end="" suppresses the default end='\n'. Note: a Python-oriented editor/IDE, such as IDLE, should, after one types print( and pauses a bit, display a call hint that shows one such options. Interactively, >>> help(print) would do the same a bit more verbosely.

1 Like