Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. def dicl(a):
  2. d = {}
  3. for i in a:
  4. if i in d:
  5. d[i] += 1
  6. else:
  7. d[i] = 1
  8. return d
  9.  
  10. def dicp(a):
  11. p = a.split(' ')
  12. d = {}
  13. for i in p:
  14. if i in d:
  15. d[i] += 1
  16. else:
  17. d[i] = 1
  18. return d
  19.  
  20. def dic2t2(a):
  21. d = {}
  22. for i in range(len(a)- 1):
  23. x = a[i:i+2]
  24. if x in d:
  25. d[x] += 1
  26. else:
  27. d[x] = 1
  28. return d
  29.  
  30. def ditupla(a):
  31. p = a.split(' ')
  32. d = {}
  33. for i in range(len(p)-1):
  34. x = tuple(p[i:i+2])
  35. if x in d:
  36. d[x] += 1
  37. else:
  38. d[x] = 1
  39. return d
  40.  
  41.  
  42.  
  43.  
  44.  
  45. def didic(a,b):
  46. d = {}
  47. for i in a:
  48. if i[0] == b:
  49. d[i] = a[i]
  50. return d
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement