How do i print a space between lines in python?

I'm making a game in Python (text only) but it gets confusing when people play it because there is no space between the paragraphs, so it looks like this:

'You step outside and feel the wind on your face.'
'Which direction do you turn?'

But I would like it to look like this:

'You step outside and feel the breeze on your face'

'What do you do next'?

Here's my code:

print 'You step outside and feel the cool breeze on your face.'
what = raw_input ('What do you do next ')

Thanks!

Amber

488k81 gold badges617 silver badges545 bronze badges

asked Apr 10, 2012 at 0:25

Print a newline character.

print("\n")

Or:

print("An angry-looking dwarf throws an axe at you.\nYou die.\n")

answered Apr 10, 2012 at 0:26

Li-aung YipLi-aung Yip

12.1k5 gold badges31 silver badges49 bronze badges

You have a few solutions:

The simpler one would be to use a print statement between your lines, which, used alone, prints a line feed.

Alternatively, you could you end the string you're printing with a '\n' character, which will cause a line feed, or you could start your input with the same character.

answered Apr 10, 2012 at 0:28

Thomas OrozcoThomas Orozco

50.8k9 gold badges108 silver badges114 bronze badges

print('\v')

vertical tab for vertical space.

answered May 3, 2017 at 13:15

How do i print a space between lines in python?

Mian Asbat AhmadMian Asbat Ahmad

3,02810 gold badges39 silver badges66 bronze badges

  • Introduction
  • What is an empty line?
  • Multiple Ways to Print a Blank line in Python
    • 1. Using print() function
    • 2. Using Print() function with single quotes to print blank line in python
    • 3. Using print() function with double quotes
    • 4. Using Print() function with a newline character To Print Blank Line In Python
    • 5. Printing multiple blank lines
  • Conclusion

Introduction

Sometimes, while programming in Python, we came to a situation where we want to print the data in a new line, a blank line between two-lines, or print the data in the same line without using the newline. This article will help you understand the concept of printing the blank line in between the two lines in deep with all the suggested ways.

What is an empty line?

An empty line is a blank line that has lots of spaces and lots of tab in them. We can also say an empty line is a blank line that has a space between the two lines.

There are many such ways present to print the blank line in python. We will be discussing all the ways to print the blank line. Let us start by taking all the ways with the help of examples:

1. Using print() function

In this example, we will be using the print() function to print the empty line between the two give lines. Let us look at the example for a better understanding of the concept:

#using print() for empty lines

str = 'latracal Solutions'
s = 'is the best website'

print(str)
print()
print(s)

Output:

latracal Solutions

is the best website

Explanation:

  • Firstly, we have taken two input strings in the variable str and s.
  • Then, we have printed the first string str.
  • After that, we have applied the print().
  • At last, we have printed the second string s.
  • We can see the output with one blank line in between the two given strings.

2. Using Print() function with single quotes to print blank line in python

In this example, we will be using print() with single quotes to print the empty line between the two given lines. Let us look at the example for a better understanding of the concept:

#using print() with single quotes for empty lines

str = 'latracal'
s = 'solutions'

print(str)
print('')
print(s)

Output:

latracal

solutions

Explanation:

  • Firstly, we have taken two input strings in the variable str and s.
  • Then, we have printed the first string str.
  • After that, we have applied the print() with single quotes inside them.
  • At last, we have printed the second string s.
  • We can see the output with one blank line in between the two given strings.

3. Using print() function with double quotes

In this example, we will be using print() with double quotes to print the empty line between the two given lines. Let us look at the example for a better understanding of the concept:

#using print() with double quotes for empty lines

str = 'latracal'
s = 'solutions'

print(str)
print("")
print(s)

Output:

latracal

solutions

Explanation:

  • Firstly, we have taken two input strings in the variable str and s.
  • Then, we have printed the first string str.
  • After that, we have applied the print() with double quotes inside them.
  • At last, we have printed the second string s.
  • We can see the output with one blank line in between the two given strings.

Also Read: How to Remove Quotes From a String in Python

4. Using Print() function with a newline character To Print Blank Line In Python

In this example, we will be using print() with having a newline character in them to print the empty line between the two given lines. The newline character is denoted by n. The newline character can be written in single and double quotes according to your preference. Let us look at the example for a better understanding of the concept:

#using print() with newline character for empty lines

str = 'latracal'
s = 'solutions'

print(str,"\n")
print(s)

Output:

latracal 

solutions

Explanation:

  • Firstly, we have taken two input strings in the variable str and s.
  • Then, we have printed the first string str.
  • After that, we have applied the print() with a newline character inside them.
  • We can print the newline character with single as well as the double-quotes.
  • At last, we have printed the second string s.
  • We can see the output with one blank line in between the two given strings.

5. Printing multiple blank lines

A. Using multiplication operator

In this example, we will be using the print() function with the newline character and * operator, who can produce multiple blank lines between the two give lines. The newline character is denoted by n. Let us look at the example for a better understanding of the concept:

#using print() with newline character with * for multiple empty lines

str = 'latracal'
s = 'solutions'

print(str)
print(5 * "\n")
print(s)

Output:

latracal






solutions

Explanation:

  • Firstly, we have taken two input strings in the variable str and s.
  • Then, we have printed the first string str.
  • After that, we have applied the print() with a newline character and * operator inside it.
  • We can print the newline character with single as well as the double-quotes. Both will work the same.
  • At last, we have printed the second string s.
  • We can see the output with multiple blank lines in between the two given strings.

B. Using multiple times newline character to print blank line in Python

In this example, we will be using the print() function with the newline character multiple times to produce multiple blank lines between the two give lines. The newline character is denoted by n. Let us look at the example for a better understanding of the concept:

#using print() with newline character writing multiple times to print multiple empty lines

str = 'latracal'
s = 'solutions'

print(str)
print("\n\n\n\n\n\n")
print(s)

Output:

latracal





solutions

Explanation:

  • Firstly, we have taken two input strings in the variable str and s.
  • Then, we have printed the first string str.
  • After that, we have applied the print() with a newline character writing multiple times inside it.
  • we can print the newline character with single as well as the double-quotes both will work the same.
  • At last, we have printed the second string s.
  • We can see the output with multiple blank lines in between the two given strings

Conclusion

In this tutorial, we have learned about how to print the blank spaces between the two lines in python in many ways. we have also learned to print multiple blank lines between two lines. All the ways are discussed with the help of examples and they are explained in detail. You can choose any of the ways to print blank lines in python according to your choice.

However, if you have any doubts or questions, do let me know in the comment section below. I will try to help you as soon as possible.

What does \t do in Python?

Learn More. In Python strings, the backslash "\" is a special character, also called the "escape" character. It is used in representing certain whitespace characters: "\t" is a tab, "\n" is a newline, and "\r" is a carriage return.

How do you print vertical space in Python?

If you want to accomplish this task, just use "\n".

How do you put a space in a string in Python?

Add spaces between the characters of a string in Python #.
Call the join() method on a string containing a space..
Pass the string as an argument to the join method..
The method will return a string where the characters are separated by a space..

How do you represent a space in Python?

In Python, characters that are used for spacing are called as whitespace characters..
' ' – Space..
'\t' – Horizontal tab..
'\v' – Vertical tab..
'\n' – Newline..
'\r' – Carriage return..
'\f' – Feed..