Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Python || Creating new lines based on user input

I am wondering how you can let a given user input create new lines automatically.
Like for instance:

summary = input("Please write a short summary")

Let the user input for example be:

An age-old vendetta between two powerful families erupts into bloodshed. A group of masked Montagues risk further conflict by gatecrashing a Capulet party. A young lovesick Romeo Montague falls instantly in love with Juliet Capulet, who is due to marry her father's choice, the County Paris.

Now I actually want this to be displayed as:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

An age-old vendetta between two powerful families erupts into bloodshed.
A group of masked Montagues risk further conflict by gatecrashing a Capulet party.
A young lovesick Romeo Montague falls instantly in love with Juliet Capulet, who is due to marry her father's choice, the County Paris.

As you can see in the last example, it is creating new lines each time.
I know you can create new lines with /n, but not how to import this into user inputs automatically, I hope you understand with the example given above.

>Solution :

How about this :

print(summary.replace('.','.\n'))

Output:

>An age-old vendetta between two powerful families erupts into bloodshed.
 A group of masked Montagues risk further conflict by gatecrashing a Capulet party.
 A young lovesick Romeo Montague falls instantly in love with Juliet Capulet, who is due to marry her father's choice, the County Paris.
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading