CBSE Class 12 Computer Science
Question 68 of 68
Data Structures - I : Linear Lists — Question 5
Back to all questions 5
Question Suppose we have a list V where each element represents the visit dates for a particular patient in the last month. We want to calculate the highest number of visits made by any patient. Write a function MVisit(Lst) to do this.
A sample list (V) is shown below :
V = [[2, 6], [3, 10], [15], [23], [1, 8, 15, 22, 29], [14]]
For the above given list V, the function MVisit() should return the result as [1, 8, 15, 22, 29].
def MVisit(Lst):
max_index = 0
for i in range(1, len(Lst)):
if len(Lst[i]) > len(Lst[max_index]):
max_index = i
return Lst[max_index]
V = [[2, 6], [3, 10], [15], [23], [1, 8, 15, 22, 29], [14]]
result = MVisit(V)
print(result)[1, 8, 15, 22, 29]