Q:

List in python not working where command are passed as string

This is the sequence of input given and we have to make a List to go thought the above commands which will be given by the user as input. 
12
insert 0 5
insert 1 10
insert 0 6
print 
remove 6
append 9
append 1
sort 
print
pop
reverse
print

The result of the following operations should be like this-

[6, 5, 10]
  [1, 5, 9, 10]
  [9, 5, 1]

The following code will read the commands given as text where the first line will be the total no of commands that have to be followed and the following command will be the given as text. But the code is not working for me it is not printing out anything.  why it is so?  please provide solution to this problem.  
L=[]
li=[]
def check(string):
for a in string:
    if a=='insert':
        li=string.split()
        L.insert(int(li[1]),int(li[2]))
        li=[]
    elif(a=='append'):
        li=string.split()
        L.append(int(li[1]))
        li=[]
    elif(a=='sort'):
        L.sort()
    elif(a=='remove'):
        li=string.split()
        L.remove(li[1])
        li=[]
    elif(a=='print'):
        print(L) 
    elif(a=='reverse'):
        L.reverse()
    elif a=='pop':
        L=L[:-2]
    else:
        pass
N=int(input(""))
for i in range(N):
    string =str(input(""))
    check(string)

A:

It looks like the code for a in string loop at method check(), iterates over each letter of the string, so no actions are performed... it always do 'pass'.