Advertisement
doxzter

Untitled

Dec 11th, 2022
629
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.58 KB | None | 0 0
  1. #1
  2. class Test:
  3.     def __init__(self, dict):
  4.         for key in dict:
  5.             setattr(self, key, dict[key])
  6.  
  7. dict = {
  8.     'a': 'Утка утка',
  9.     'b': 'Утка утка',
  10.     'c': 'Утка утка',
  11. }
  12.  
  13. obj = Test(dict)
  14.  
  15. #2
  16. text = '''But soft what light through yonder window breaks
  17. It is the east and Juliet is the sun
  18. Arise fair sun and kill the envious moon
  19. Who is already sick and pale with grief'''
  20.  
  21. words = {}
  22.  
  23. for w in text.replace('\n', ' ').split(' '):
  24.     try:
  25.         words[w] = words[w] + 1
  26.     except:
  27.         words[w] = 1
  28.  
  29. print(words)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement