ctrlcctrlv

python sol

Mar 2nd, 2021
823
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import re,itertools
  2. # Online Python compiler (interpreter) to run Python online.
  3. # Write Python 3 code in this online editor and run it.
  4. text = """It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like)."""
  5. text = re.sub(r'[\.,\'\(\)]','',text)
  6. print(text)
  7. words = text.split(" ")
  8. print(words.count("here"))
  9. freq = {}
  10. for i in words:
  11.     if(i in freq.keys()):
  12.         continue
  13.     elif(words.count(i)<3):
  14.         freq[i] = words.count(i)
  15.        
  16. less_freq = dict(sorted(freq.items(), key=lambda item: item[1]))
  17. print(freq)
  18. print(dict(itertools.islice(less_freq.items(), 20)))
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×