List Clear in Python
Level 247 keystrokes
This removes all elements from a list using the clear() method, leaving an empty list.
Python code
# Create a list with five numbers1nums = [1, 2, 3, 4, 5]# clear() removes all elements from the list# The list becomes empty but still exists2nums.clear()# Print the now-empty list3print(nums)Output
[]
Practice typing this code. Results are not recorded in the rankings.
Symbols in this code
The symbols you type in this Python code and how often they appear.
,× 4(× 2)× 2.× 1[× 1]× 1=× 1