-1

Perhaps there may be a simpler way to do what I am asking for. I have to print a body of text as I have posted below.

I know in bash, I can echo and enter new lines to keep my lines not too long (under 12-13 words per line). In python, the print statement strings needs to be one long string separated by "\n". However, if I need to print a large body of texts it gets ugly. (python newbie here)

using echo

echo " Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. "

using print

> print(Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod\n tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam\n, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo\n consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

As you can see the first one is easier to read as it does not require scrolling to view/type the text (using vscode) Is there any way I can print to the screen large body of texts in python?

0

1 Answer 1

0

Use multiline strings:

print('''
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed 
do eiusmod tempor ncididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco
laboris nisi ut aliquip ex ea commodo consequat.
''')
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.