Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- slownik = {'a': 2, 'b' : 1, 'c':1}
- lista = ['acab', 'bca', 'aabc', 'aab', 'bc']
- czestosc = []
- powtarzajaceSie = []
- for slowo in lista:
- wystA = slowo.count('a')
- wystB = slowo.count('b')
- wystC = slowo.count('c')
- wyst = {'a':wystA,'b':wystB,'c' : wystC}
- czestosc.append(wyst)
- def funct(dictionary):
- same = 0;
- if(dictionary['a']==slownik['a']):
- same+=1
- if(dictionary['b']==slownik['b']):
- same+=1
- if(dictionary['c']==slownik['c']):
- same+=1
- return same
- for sl in czestosc:
- powtarzajaceSie.append(funct(sl))
- print(powtarzajaceSie)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement