If I have a string thats 'asdf foo\nHi\nBar thing', I want it to split the string, so the output is ['asdf', 'foo', 'hi', 'bar', thing']. Thats essentially x.split(' ') and x.split('\n'). How can I do this efficiently? I want it to be about one line long, instead of having a for loop to split again…
If I have a string thats ‘asdf foo\nHi\nBar thing’ , I want it to
Share
Omit the parameter to
split():x.split()will split on both, spaces and newline characters (and also tabs).Example: