CBSE · 083Class XII · 2023Section B1 mark
Question 21(1)
30 March 2023 · Computer Science (083)
Given is a Python list declaration : Listofnames=["Aman","Ankit","Ashish","Rajan","Rajat"] Write the output of : print (Listofnames [-1:-4:-1])
Answer
['Rajat', 'Rajan', 'Ashish']
Explanation
Slicing [-1:-4:-1] starts at the last element, moves backwards, and stops before the 4th element from the end.