0

How to clear the KivyMD List 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?

jonrsharpe
  • 107,083
  • 22
  • 201
  • 376
bobk810i
  • 23
  • 2

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,006
  • 9
  • 17