I have a list:
my=['A', 'kk','lo','A','o','t','A','t']
I want to make a nested list whenever I there is an 'A'
in the list
Example output:
my_nest=[['A', 'kk','lo'],['A','o','t'],['A','t']]
I tried to do that but not sure how make it work:
my_nest=[]
my_nest_sub=[]
for i in my:
if i!='A':
my_nest_sub.append(i)
elif i=='A':
my_nest.append(my_nest_sub)
my_nest_sub=[]