Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python: iterate over a string containing newlines [duplicate]

Tags:

I have a string separated by newline characters, I need to work with each line individually. I though I would be able to iterate over by using a for loop. However this prints each character individually.

Example:

convo = "Bob: Hello \n Sandy: How are you? \n Bob: Confused by a python problem"

for line in convo:
    print(line)

>>> B
>>> o
>>> b
>>> :

What would be the best way to do this?