Informatics Practices
The list L1 contains [3, 4, 5, 6, 6, 8, 0]. What will be the output of the following expression?
print(L1 [-1])
- 0
- 3
- 5
- 8
Python List Manipulation
2 Likes
Answer
0
Reason — In Python, negative indexing allows to access list elements starting from the end. The index -1 refers to the last element in the list. For the list L1 = [3, 4, 5, 6, 6, 8, 0], the last element is 0. So the output of print(L1[-1]) is 0.
Answered By
2 Likes
Related Questions
extend() function is used to add multiple list items in a list.
Consider the following statement:
List = ['h', 'o', 'i']The length of the above list is:
- 5
- 3
- 0
- None of these
Which of the following statements is correct about list?
- List can contain values of mixed data types.
- List can contain duplicate values.
- A list with no elements is called an empty list.
- All of these
Which operator can be used with list?
- in
- not in
- Both 1 & 2
- Arithmetic Operators only