English

Given is a Python list declaration: Listofnames = ["Aman", "Ankit", "Ashish", "Rajan", "Rajat"] Write the output of: print (Listofnames [−1:−4:−1]) - Computer Science (Python)

Advertisements
Advertisements

Question

Given is a Python list declaration:

Listofnames = ["Aman", "Ankit", "Ashish", "Rajan", "Rajat"]

Write the output of:

print (Listofnames [−1:−4:−1])
Code Writing
Advertisements

Solution

Output:

["Rajat", "Rajan", "Ashish"]

Explanation:

Listofnames [−1:−4:−1] returns elements from index −1 to −3, decrementing by −1. 

shaalaa.com
  Is there an error in this question or solution?
2022-2023 (March) Set 4
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×