Add new line python

A simple one!

In Python, you can add a new line using the following methods:

  1. Print statement with a newline character:

    print("Hello", end="\n")

    The end parameter is used to specify the character to be printed after the string. By default, it's a space, but by setting it to "\n", you can add a new line.

  2. Print statement with a newline character and a string:

    print("Hello\nWorld")

    This will print "Hello" followed by a new line and then "World".

  3. Using the print() function with multiple arguments:

    print("Hello", "World")

    This will print "Hello" and "World" on the same line, separated by a space.

  4. Using the print() function with a newline character and a string:

    print("Hello")
    print("World")

    This will print "Hello" on one line and then "World" on the next line.

  5. Using the os module:

    import os
    os.system("echo Hello\nWorld")

    This will print "Hello" followed by a new line and then "World" using the os module.

Note that the print() function in Python 3.x is more flexible than in Python 2.x, and you can use it to print multiple values on the same line or on separate lines.