1

I'm trying to separate some outputted text in Python 3. Heres sorta an example of what iv got now

print("words")
print("")
print("")
print("")
print("")
print("")
print("")
 #(Print would keep going on like 50 times)...
print("more words")

now putting all those prints is annoying and i need the words to be vertically seperated. like this

words









more words

Any ideas on how to separate huge verticle distances. Thanks :)

2
  • 6
    print('\n' * 50) Commented Aug 21, 2017 at 13:44
  • 1
    use \n . Ex : print("words \n\n\n\n\n\n") OR in your case print('\n' * 50) Commented Aug 21, 2017 at 13:45

2 Answers 2

3

You could put a newline character "\n" in the string, e.g.

>>> print ("\n\n\n\n")

Characters preceded by a backslash are 'escaped', and are converted to special characters by Python. Some commonly used escape sequences are:

  • Newline "\n"
  • Tab "\t"
  • Carriage Return "\r"
  • Backslash "\\"
  • Hexadecimal character code "\x0f"
  • Quote character "\"" or '\''

Note that strings can be repeated by multiplying them with a number, e.g.

>>> print ("\n" * 100)
Sign up to request clarification or add additional context in comments.

Comments

2

You can construct a string of newline characters, which will result in vertical space, like this:

lines = 5  # Number of blank lines
print("\n" * lines) 

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.