Advertisement
STANAANDREY

freq from string arr

Jan 16th, 2023
522
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.39 KB | None | 0 0
  1. import functools
  2.  
  3.  
  4. def getFreq(lst):
  5.     freq = dict()
  6.     def reducer(acc, elem):
  7.         def reducer2(acc2, elem2):
  8.             if elem2 not in freq.keys():
  9.                 freq[elem2] = 1
  10.             else:
  11.                 freq[elem2] += 1
  12.         functools.reduce(reducer2, elem, None)
  13.     functools.reduce(reducer, lst, None)
  14.     return freq
  15.  
  16. print(getFreq(['aaa', 'bbb', 'aabbb']))
  17.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement