remove all elements from a list

PHOTO EMBED

Tue Jun 18 2024 16:56:13 GMT+0000 (Coordinated Universal Time)

Saved by @pynerds #python

#a list of strings
mylist = ['Python', 'Java', 'C++', 'Ruby']

#remove all elements from the list
mylist.clear()

#the list is now empty
print(mylist)
content_copyCOPY

https://www.pynerds.com/list-clear-method-in-python/