image of code if not understandable
The image shows the code I have written, I want to swap item positions but I am getting list indices must be integer or slice not string. I have tried many different ways but still dont seem to get the hang of it.
choice = ""
lists = []
while True:
choice = input("Try out inv commands: ")
if choice == 'inv':
    print('Backpack has ' + str(len(lists)) + ' iteams: ' + str(lists))
elif 'inv pick' in choice:
    iteams1 = choice.split('inv pick ')
    iteams2 = iteams1[1].split(' ')
    try:
        if iteams2[1] != '':
            add = lists.insert(int(iteams2[1]), iteams2[0])
            print(str(iteams2), ' has been added')
    except IndexError:
        lists.extend(iteams2)
elif 'inv drop' in choice:
    iteams1 = choice.split('inv drop ')
    iteams2 = iteams1[-1].split(' ')
    if iteams2[-1] != '':
        removed = lists.remove(iteams2[0])
        print(str(iteams2), ' has been dropped')
elif 'inv swap' in choice:
    iteams1 = choice.split('inv swap')
    iteams2 = iteams1[1].split(' ')
    try:
        if iteams2[1] != '':
            pos1, pos2 = iteams2[2], iteams2[1]
            lists[pos1], lists[pos2] = lists[pos2], lists[pos1]
            print('swapped ')
    except IndexError:
        enter code herelists.extend(iteams2)
 
     
     
     
    