Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Python Clearing a List

Python Clearing a List

Document Object Reference Manual Python3 Examples

Define a list and clear it; this can be done with the clear() method.

Example 1

RUNOOB

=

[

6

,

0

,

4

,

1

]

print

(

'Before clearing:'

,

RUNOOB

)

 

 

RUNOOB.

clear

(

)

print

(

'After clearing:'

,

RUNOOB

)

 

The output of the above example is:


清空前: [6, 0, 4, 1]
清空后: []

Document Object Reference Manual Python3 Examples