How to split a string by newline in Python

1 Answer

0 votes
s = "python\nc#\njava\nc\nc++"

lst = s.splitlines()

print(lst)


'''
run:

['python', 'c#', 'java', 'c', 'c++']

'''

 



answered May 30, 2023 by avibootz
...