Robotics & Artificial Intelligence
What would be the output of following code ?
list1 = [2, 3, 4, 5, 6]
print(list1[-2])
- 3
- 4
- 5
- Error
Python List Manipulation
3 Likes
Answer
5
Reason — In negative indexing, the index -1 refers to the last element of the list and -2 refers to the second last element, which is 5 in the given list.
Answered By
1 Like
Related Questions
What is the meaning of intellectual property infringement?
- Sending a mail that includes a link to a fake site
- Stealing software that may be stored on a pen drive
- Make a copy of someone’s patent design
- None of these
A module in Python is …………… .
- A function
- Collection of variables
- Collection of Python code in a file
- None of these
Which of the following function is applicable in a tuple?
- insert
- append
- del
- None of these
What would be the output of following code?
str1 = "Hello India" s1 = str1[1:3] print(s1)- He
- el
- Hlo
- None of these