Q. 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 ]
Answer =
def MVisit( lst ) : max_index = 0 for i in range( len( lst ) ): if len( lst[ i ] ) > max_index : max_index = i return lst [ max_index ] v = eval(input("Enter vist list :-")) print( "Highest number of visits :-", MVisit( v ) )
def MVisit(l) :
ReplyDeletemax_l = []
for i in l :
if len(i) > len(max_l):
max_l = i
return max_l
v = eval(input("Enter vist list :-"))
print( "Highest number of visits :-", MVisit( v ) )
It is from Jinsu
DeleteDon't forget to indent properly
DeleteRight program : )
DeletePost a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )