-1
s = "how many gallons
     of rain did you drink
                                cuckoo"

above 3 lines are input , I want to create a list=["how many gallons", "of rain did you drink", "cuckoo"]

U13-Forward
  • 69,221
  • 14
  • 89
  • 114
Anke
  • 19
  • 5
  • I thought about it while solving a problem, is it simple to do or code for it is complicated ,if latter is the case then I will think to solve the problem with some other approach. – Anke Dec 20 '20 at 09:04
  • Does this answer your question? [Split string using a newline delimiter with Python](https://stackoverflow.com/questions/22042948/split-string-using-a-newline-delimiter-with-python) – Georgy Dec 22 '20 at 10:12

1 Answers1

2

Use splitlines:

print([i.strip() for i in s.splitlines()])

Output:

['how many gallons', 'of rain did you drink', 'cuckoo']
U13-Forward
  • 69,221
  • 14
  • 89
  • 114