Advertisement
Guest User

Untitled

a guest
Jan 21st, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. slownik = {'a': 2, 'b' : 1, 'c':1}
  2.  
  3. lista = ['acab', 'bca', 'aabc', 'aab', 'bc']
  4.  
  5. czestosc = []
  6.  
  7. powtarzajaceSie = []
  8.  
  9. for slowo in lista:
  10. wystA = slowo.count('a')
  11. wystB = slowo.count('b')
  12. wystC = slowo.count('c')
  13. wyst = {'a':wystA,'b':wystB,'c' : wystC}
  14. czestosc.append(wyst)
  15.  
  16. def funct(dictionary):
  17. same = 0;
  18. if(dictionary['a']==slownik['a']):
  19. same+=1
  20. if(dictionary['b']==slownik['b']):
  21. same+=1
  22. if(dictionary['c']==slownik['c']):
  23. same+=1
  24. return same
  25.  
  26. for sl in czestosc:
  27. powtarzajaceSie.append(funct(sl))
  28.  
  29. print(powtarzajaceSie)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement