title: Python ranking and lists
body: <p>I have this script that is suppose to rank fruits based on a number.</p>
  
  <pre><code>#! /usr/bin/python
  fruits = {'Apple':1,'Banana':2,'Pineapple':3}
  alist = [(v, k) for k, v in fruits.items()]
  alist.sort(reverse=False)
  fruit_order = str(alist).translate(None, "[]()'123456789").replace(", , ",    "    ,     ",").replace(" ", "")[1:]
  print fruit_order
  </code></pre>
  
  <p>fruits is actully a list made up with check with .append(fruits)</p>
  
  <pre><code>#! /usr/bin/python
  import re
  from configobj import ConfigObj
  config = ConfigObj('sites.conf')
  fruits = []
  
  substance = "juice"
  target_list = config['MainConfig']['fruits']
  for target in target_list:
    if re.search( config[target]['Skiplist'], substance, re.M|re.I):
       target = target + "'" + ":" + config[target]['Rank'] + ","
       fruits.append(target)
    else:
     print "Dident pass"
  fruits1 = "{'" + "'".join(fruits) + "}"
  alist = [(v, k) for k, v in fruits1.list()]
  alist.sort(reverse=False)
  fruit_rank = str(alist).translate(None, "[]()'123456789").replace(", , ", ",").replace(" ", "")[1:]
  </code></pre>
  
  <p>print fruit_rank in example 2 prints out a line that looks exactly like test in example 1.</p>
  
  <p>But iam still getting an error on example2, AttributeError: 'str' object has no attribute 'list'</p>
  
  <p>And i can not really figure this one out. How would i do it?</p>
  
  <p>What iam looking for is in the config file i have a rank for each fruit, the line should print out the fruits in its rank.</p>