OrangeFoxMan
OrangeFoxMan

Reputation: 1

How to have a blank line between sets of print statements?

I am having this small issue where my code is not printing any blanks between sets of print statements.

    print(countries[11], file=output_file)
    print(countries[17], file=output_file)

    print("Continent:", continents[3], file=output_file)
    print("Currency:", currency[3], file=output_file)

There should be a blank line between these two sets, but there isn't. Any insight would be greatly appreciated.

I have tried using \n but I do not know where to put it since my code is a little complicated (to me at least). I was expecting it to print kinda like this, with a blank line between them. print statement print statement

print statement print statement

Upvotes: 0

Views: 2024

Answers (3)

Kendal Minor
Kendal Minor

Reputation: 1

there are a couple ways you could do this. You can either do something like printing a line in between manually

print(countries[11], file=output_file)
print(countries[17], file=output_file)
print()
print("Continent:", continents[3], file=output_file)
print("Currency:", currency[3], file=output_file)

or you could write it into the end parameter of the print statement like this:

print(countries[11], file=output_file)
print(countries[17], file=output_file, end="\n\n") # \n\n just puts a second line break after the first

print("Continent:", continents[3], file=output_file)
print("Currency:", currency[3], file=output_file)

Upvotes: 0

BuggerMeNot
BuggerMeNot

Reputation: 88

You could probably try rewriting the 3rd line like this. print("\nContinent:", continents[3], file=output_file)

Upvotes: 1

nemborkar
nemborkar

Reputation: 31

Here's a quick and simple way to do what you are trying to achieve

print(countries[11], file=output_file)
print(countries[17], file=output_file)
print()
print("Continent:", continents[3], file=output_file)
print("Currency:", currency[3], file=output_file)

Upvotes: 1

Related Questions