+1 vote
in Computer by (30 points)
Given the list l =[2,5,4,9,10,11,20] write the output print (L[2:6]

Please log in or register to answer this question.

1 Answer

0 votes
by (2.1k points)
edited by

print (L[2:6]) means print all the values in list from index value 2 to 6

Since, index starts from 0, so the value at index 2 is 4 and at index 6 is 20.

But the item at position 6 will not be included.

Therefore output will be [4,9,10,11].

Note: The search will start at index 2 (included) and end at index 6 (not included).

Remember that the first item has index 0.

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.