Print() of several text strings, twice no space, otherwise space between


again a beginner question. I tried to format the code. I apologise if it did not work.

I have this line:
<print(“My name is”, given_name, “,”, given_name, family_name, “.”)>
e.g. My name is John , John Williams .

How could I write this line so I have the print
My name is John, John Williams. ?

I have tried:
<print(“My name is”, given_name, sep=“”, “,”, given_name, family_name, sep=“”, “.”) end=\n>
<print(“My name is”, print(given_name, sep=" “) end=” “, “,”, given_name, print(family_name, sep=” ") end = " ", “.”)>
<print(“My name is”, f{given_name}{,}, given_name, f{family_name}{.})>

I know this <print(f{word_1}{word_2})> works for two text strings alone in one print(), but if the contains more text strings, then I longer have no idea.

Thank you in advance.

Please wrap code in triple backticks to preserve the formatting:

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

Using an f-string:

print(f"My name is {given_name}, {given_name} {family_name}.")

or by setting sep:

print("My name is ", given_name, ", ", given_name, " ", family_name, ".", sep="")
1 Like

Thank you for the help and patience. I will in the future add those triple backticks.