-2

I would like a string with var1 on the first line and var2 on second line. It would look like this printed:

Var1

Var2

would the code be

product = str(var1 /n + var2)
print(product)

?

2
  • 1
    But I mean come on, this takes 3secs to google and is not a suitable question for SO Commented Oct 28, 2020 at 23:57
  • Also see: Printing variables in Python 3.4 Commented Oct 29, 2020 at 0:00

1 Answer 1

1

There are many ways this can be done, but what you are suggesting will not work. Here are a few ways

print("%s\n%s" %(var1, var2))
print("{}\n{}".format(var1, var2))
print(f"{var1}\n{var2}") # python >= 3.6
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.