title: How to print every variable from biggest to smallest in python
body: <p>I'm working on a zif's law project in python. I wrote this code:</p>
  <pre><code>import os
  my_file = open(&quot;words.txt&quot;, &quot;r&quot;)
  content = my_file.read()
  w = content.split()
  my_file.close()
  
  def split(a):
      return[char for char in a]
  
  x = 0
  for i in range(len(w)):
      w[x] = w[x].lower()
      s = split(w[x])
  
      y = 0
      for i in range(len(s)):
          if s[y] == &quot;.&quot; or s[y] == s[y] == &quot;,&quot; or s[y] == &quot;'&quot; or s[y] == &quot;0&quot; or s[y] == &quot;1&quot; or s[y] == &quot;2&quot; or s[y] == &quot;3&quot; or s[y] == &quot;4&quot; or s[y] == &quot;5&quot; or s[y] == &quot;6&quot; or s[y] == &quot;7&quot; or s[y] == &quot;8&quot; or s[y] == &quot;9&quot;:
              s[y] = ''
          y += 1
  
      s = &quot;&quot;.join(s)
      w[x] = s
      x += 1
  
  
  
  
  
  o = open(&quot;wzl.py&quot;, &quot;w&quot;)
  x = 0
  p = 0
  for i in range(len(w)):
      if x == (len(w) - 1):
          break
      y = 0
      o.write(f&quot;{w[x]}1 = 1&quot;)
      o.write(&quot;\n&quot;)
      for i in range(len(w) - 1):
          y += 1
  
          if w[x] == w[y]:
              o.write(f&quot;{w[x]}1 += 1  &quot;)
              o.write(&quot;\n&quot;)
              del w[y]
              y -= 1
  
  
  
          if y == (len(w) - 1):
              o.write(f&quot;print('{w[x]} = ', {w[x]}1)&quot;)
              o.write(&quot;\n&quot;)
              del w[x]
              x -= 1
  
      print(w)
      x += 1
  
  o.close()
  os.system(&quot;python wzl.py&quot;)
      
  </code></pre>
  <p>It opens the other file and writes this:</p>
  <pre><code>sitting1 = 1
  print('sitting = ', sitting1)
  in1 = 1
  in1 += 1  
  print('in = ', in1)
  the1 = 1
  the1 += 1  
  print('the = ', the1)
  sun1 = 1
  print('sun = ', sun1)
  away1 = 1
  print('away = ', away1)
  from1 = 1
  print('from = ', from1)
  everyone1 = 1
  print('everyone = ', everyone1)
  who1 = 1
  print('who = ', who1)
  had1 = 1
  print('had = ', had1)
  done1 = 1
  print('done = ', done1)
  him1 = 1
  print('him = ', him1)
  harm1 = 1
  print('harm = ', harm1)
  </code></pre>
  <p>Now, all I need is for the code to go through every variable and print the first 10 from biggest to smallest, how do I do that? I think i can do it with class but i don't know how to use it.</p>
  <p>Also if you find some way I can improve my code, please note.</p>
  <p>Input example:
  'Sitting in the sun, away from everyone who had done him harm in the past.'</p>
  <p>Output example:</p>
  <pre><code>the: 6
  he: 5
  of: 2
  she: 1
  </code></pre>