Change List Items
Learn all about Change List Items in this comprehensive tutorial.
- •To change the value of a specific item, refer to the index number:
- •To change the value of items within a specific range, define a list with the new values, and refer to the range of index numbers where you want to insert the new values:
- •To insert a new list item, without replacing any of the existing values, we can use the insert() method.
Change Item Value
To change the value of a specific item, refer to the index number:
Change a Range of Item Values
To change the value of items within a specific range, define a list with the new values, and refer to the range of index numbers where you want to insert the new values:
If you insert more items than you replace, the new items will be inserted where you specified, and the remaining items will move accordingly:
If you insert less items than you replace, the new items will be inserted where you specified, and the remaining items will move accordingly:
Insert Items
To insert a new list item, without replacing any of the existing values, we can use the insert() method.
The insert() method inserts an item at the specified index:
Module quiz
2 questionsWhich of the following is true about Change List Items?
What is the most common pitfall when working with Change List Items?
Answer all questions to submit.