So I have this txt file:
Haiku
5 *
7 *
5 *
Limerick
8 A
8 A
5 B
5 B
8 A
And I want to write a function that returns something like this:
[['Haiku', '5', '*', '7', '*', '5', '*'], ['Limerick', '8', 'A', '8', 'A', '5', 'B', '5', 'B', '8' ,'A']]
Ive tried this:
small_pf = open('datasets/poetry_forms_small.txt')
lst = []
for line in small_pf:
lst.append(line.strip())
small_pf.close()
print(lst)
At the end I end up with this:
['Haiku', '5 *', '7 *', '5 *', '', 'Limerick', '8 A', '8 A', '5 B', '5 B', '8 A']
My problem is that this is one big list, and the elements of the list are attached together, like '5 *' or '8 A'. I honestly don't know where to start and thats why I need some guidance into what to do for those two problems. Any help would be greatly appreciated.