Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def repeat_number(n, lst):
- repeat = 1
- while n < (len(lst) - 1):
- if lst[n] != lst[n+1]:
- return repeat
- else:
- repeat = repeat +1
- n = n+1
- # print repeat
- return repeat
- def longest_repetition(lst):
- dictA = {}
- n = 0
- if len(lst) == 0:
- return None
- while n < len(lst):
- if lst[n] not in dictA:
- dictA[lst[n]] = 0
- if repeat_number(n, lst) > dictA[lst[n]]:
- dictA[lst[n]] = repeat_number(n, lst)
- n = n+1
- # print dictA
- return max(dictA, key=dictA.get)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement