Printing multiple blank lines in python
Asked Answered
P

2

16

Is there a way that you can print more than one blank line in a programme, without having to type

print("\n")

load of times?

For example, I want to have a blank page (about 40 lines, I think) before my next line of text

Poyssick answered 24/1, 2015 at 21:37 Comment(3)
@jonrsharpe Don't think this is a duplicate. The answers in particular -- the accepted one here, and several there -- are especially good and distinct.Kreindler
@BobStein-VisiBone I'm not sure I understand your point - you seem to be saying that the answers there are good. If you think the answer below should also be on the duplicate, either comment on the answer or just add it yourself (it's already there as a comment, by the looks of things). If you can clarify why you think this isn't a duplicate, by all means vote to reopen, but I am unconvinced as yet.Furtek
Thanks @jonsharpe. No I think the answer below belongs here. It doesn't belong there. The reason this question is not a duplicate: arriving googlers may very well want to generate lots of blank lines for reasons other than clearing an entire screen, so they would be served here, and not there. The answer below is an especially tidy trick for doing that. And it's especially klunky for clearing a screen. (Point of order, I don't believe I have the rep to vote to reopen. Or am I not seeing the gizmo to click for that?)Kreindler
I
30

Just use multiplication, this will repeat your string however many times you'd like, in this case new lines

>>> print('\n' * 40)
Insignia answered 24/1, 2015 at 21:38 Comment(0)
P
-1

You want to print one black line in program use simple code here some example :

print('\n') print("welcome to python")

output:

welcome to python

Peeved answered 7/5, 2020 at 13:29 Comment(2)
The question was more about the repetition, not the how. How does your answer scale to 40 blank lines?Gnu
Your answer has very little to do with the question. It is not about how to add "a line" but about adding "n" number of them without using the '\n' character all the time for adding a single line.Waterworks

© 2022 - 2024 — McMap. All rights reserved.