2

How to clear a KivyMD MDList of all of the dynamically created Items? Example:

for x in range(10):
   item = OneLineListItem(text=str(x))
   self.List.add_widget(item)

We've got a list with 10 items now. I want to create a function that will remove all of them leaving the list empty. Is there any inside function to get something like that?

Superdooperhero
  • 7,584
  • 19
  • 83
  • 138
bobk810i
  • 53
  • 6

1 Answers1

1

Try list.clear(). that would remove all the elements of the list.

a = [1,2,3]
a.clear()
a
Out[4]: []
Anurag Reddy
  • 1,159
  • 11
  • 19