I've made a list of lists from a text block where each list contains all the words in a line as a separate element, like this:

```
listoflists = [['Lorem', 'ipsum', 'dolor', 'sit', 'amet\n']
               ['consectetur', 'adipiscing', 'elit', 'donec', 'iaculis\n']]

```

I want to be able to move through the list of lists, and remove the '\n' from the last element of each list in the list of lists.

This is the script I wrote to try to do this, but it doesn't work because when I return n, it only returns the first element of the first list.

```
def remove_linebreaks(input):
for i in data:
    for n in i:
        if '\n' in n:
            n.strip('\n')
            return n
        else:
            return n
return input

```

Are there any other ways I could do this?