Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2025 Foundation Course
NEET 2025 Foundation Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
+1 vote
869 views
in Computer by (22.7k points)
Give an example to update single or multiple elements of lists

1 Answer

+1 vote
by (28.2k points)
selected by
 
Best answer

You can update single or multiple elements of lists by giving the slice on the lefthand side of the assignment operator, and you can add elements in a list with the append( ) method. Following is a simple example:

# !/user/bin/python

listl = [‘physics’, ‘chemistry’, 1997, 2000];

print “Value available at index 2 :”

print list[2];

list[2] = 2001;

print “New value available at index 2 :”

print list [2];

Note: append)) method is discussed in subsequent section.

When the above code is executed, it produces the following result:

Value available at index 2 :

1997

New value available at index 2 :

2001

Related questions

+1 vote
1 answer
+1 vote
1 answer
+1 vote
1 answer
0 votes
1 answer
asked Jun 15, 2023 in R by kvdevika (112k points)

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...