Informatics Practices
Which of the following functions will return the first occurrence of the specified element in a list?
- sort()
- value()
- index()
- Sorted()
Python List Manipulation
3 Likes
Answer
index()
Reason — The index() function in Python returns the index of first matched item from the list.
Answered By
2 Likes
Related Questions
Consider the following code:
>>>A = [10, 20, 30, 40] >>>B = A.copy() >>>A[2] = 50 >>>BWhich of the following will be the elements of list A and B?
- A = [10, 20, 50, 40]
B = [10, 20, 30, 40] - A = [10, 20, 30, 40]
B = [10, 20, 50, 40] - A = [10, 20, 30, 40, 50]
B = [10, 20, 50, 40] - A = [10, 20, 40]
B = [10, 20, 50, 40]
- A = [10, 20, 50, 40]
Consider the following lists:
A = [1,2] B = [1,2]What will be the output of the following?
print(A==B)- True
- False
- Error
- No output
Given A = "[22, 4.88, "India", "T"]" the data type of A is
- List
- String
- Dictionary
- Tuple
Find the output of the following code:
number = [1, 5, 7, 0, 4] print(number[2:3])- [5]
- [7]
- [7,0]
- None of these