List: ['2\n','3\n',9\n]
I tried using delete and split, however I cannot delete / split '\n' specifically.
How do I remove \n from each entry?
List: ['2\n','3\n',9\n]
I tried using delete and split, however I cannot delete / split '\n' specifically.
How do I remove \n from each entry?
You can use strip to remove \n
Let
l = ['2\n','3\n','9\n']
l = [ x.strip() for x in l ]
This will not convert your list into int to convert it into a int list you can do:
l = [ int(x) for x in l ]