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
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)
You could probably try rewriting the 3rd line like this. print("\nContinent:", continents[3], file=output_file)
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)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.