How to make a nested list from a list when a certain character appears?

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=[]

Answer

Your loop logic is off, to fix it try something like this:

my_nest=[]
my_nest_sub=[]
for i in my:
    if i=='A':
        if my_nest_sub:
            my_nest.append(my_nest_sub)
        my_nest_sub=[]
    my_nest_sub.append(i)
my_nest.append(my_nest_sub)

For example, if you want 'A' to be in your my_nest sublists, why do you never append i when it is 'A'?

As Prune said, next time try to insert some print functions to better understand what your code actually does.