In: Computer Science
def hiCount(iterable): rtnVal = 0 most = '' for item in iterable: num = iterable.count(item) if num > rtnVal: most = item rtnVal = num return tuple(most, rtnVal) lyric = "you don't own me" print(hiCount(lyric))
does all the for then the return
Python
Here is the correct answer...
CODE:
def hiCount(iterable):
'''program to print chracter which occur max times '''
rtnVal = 0
most = ''
for item in iterable: #traverse through string iterable
num = iterable.count(item) #count occurence of charcter
#print(num)
if num > rtnVal: #find max count
most = item #mark down the character
rtnVal = num #store max count
#return tuple([most,rtnVal]) #correct usage of tuple function
#it takes one argument as parameter
return (most, rtnVal) #here it returns tuple of most and
rtnval
lyric = "you don't own me"
#print(hiCount.__doc__)
print(hiCount(lyric))
CODE Snapshot:
OUTPUT:
If you have any doubts please COMMENT...
If you understand the answer please give THUMBS UP...