stay Python in List How to use 2-1_hou09tian The blog of -CSDN Blog
I mentioned , It can be accessed by index “ list ” The elements in . therefore , Can be modified by index “ list ” The value of the element in , Pictured 1 Shown .
chart 1 modify “ list ” The value of the element
among ,squares[3] Express “ list ”squares Fourth element in , The initial value of this element is 16, The modified value changes to 10.
It can also be modified by interval index “ list ” The value of the element in , Pictured 2 Shown .
chart 2 Modify by interval indexing “ list ” The value of the element in
among ,squares[2:4] Express squares The third and fourth elements in .
adopt “ list ” Variable call append() Function to “ list ” Additive elements , Pictured 3 Shown .
chart 3 Additive elements
among ,squares.append(36) It means that you will “36” Add to squares Tail of .
You can use as shown in the figure 4 Delete as shown in “ list ” Data in .
chart 4 Delete “ list ” The elements in
adopt len() Function to obtain “ list ” The number of elements in , Pictured 5 Shown .
chart 5 obtain “ list ” The number of elements in
among ,len() The arguments to the function are specified “ list ” Variable , The return value is the “ list ” The number of elements in the variable .