Python Print New Line: 4 Easy Methods

In Python, there are several ways to print a new line, such as:

  1. Use the escape character \n:
print("Hello\nWorld")
  1. Use multiple print statements.
print("Hello")
print("World")
  1. Use the string concatenation operator\n:
print("Hello" + "\n" + "World")
  1. Using the end parameter in the print function:
print("Hello", end="\n")
print("World")

The above are some commonly used methods, which can be chosen according to specific needs.

bannerAds