Hello.
mylist = [6, '/', 3, '+', 9, '+', 8, '+', 1, '/', 2]
How can i delete that list indexes?
I tried:

    def clear(self, event):
        global numbers
        for i in numbers:
            print i
            del numbers[i]

But it didn't work:

   File "./kivycal", line 83, in clear
     del numbers[i]
 TypeError: list indices must be integers, not str

What can i do for that?

mylist = [6, '/', 3, '+', 9, '+', 8, '+', 1, '/', 2]
print(mylist)
# replace mylist with an empty list
mylist = []
print(mylist)   # --> []

mylist = [6, '/', 3, '+', 9, '+', 8, '+', 1, '/', 2]
# delete part of a list, keep the first 7 elements
del mylist[7:]
print(mylist)   # --> [6, '/', 3, '+', 9, '+', 8]

mylist = [6, '/', 3, '+', 9, '+', 8, '+', 1, '/', 2]
# delete part of a list, keep the last 3 elements
del mylist[:-3]
print(mylist)   # --> [1, '/', 2]

Edited 1 Year Ago by vegaseat

This question has already been answered. Start a new discussion instead.