Give an example to update single or multiple elements of lists
Answers
Answered by
1
Through providing the slice on the left side of the assignment operator you can change single or multiple elements of the lists, and you can add items to a list using the append) (form.)
Explanation:
- /user / bin / python listl = ['physics', 'chemistry' 1997, 2000]; print 'Price Available in index 2:' print list[2]; list[2] = 2001; print 'Current Price Available in index 2:' print list[2]; note: append))) is addressed in the next portion.
- Once the code above is performed, the outcome will be as follows: value available at index 2: 1997 Current value available at index 2: 2001
Similar questions
Math,
5 months ago
English,
5 months ago
Political Science,
5 months ago
Computer Science,
11 months ago
Computer Science,
11 months ago
Math,
1 year ago
Math,
1 year ago