Im trying to make a list from a string with multiple lines. So every new item in the list will be an entire word, I made it, but I was curious to know if it could be done with list comprehension. Im just a beginner*
list:
listExample = """example1
example2
example3"""
I solved it with:
listE = ['']
for n in listExample:
if n == '\n':
listE.insert(0, '')
else:
listE[0] = listE[0] + n
del listE[0]
print(listE)
But, is it possible with list comprehension?
Sorry, I messed it up (forget to include the list listE)