assign using () creates tuple not a list. Tuples have not .sort() method. correct would be: ncount = [key,val]
On Tue, Aug 11, 2015 at 9:01 PM, Ltc Hotspot <ltc.hots...@gmail.com> wrote: > Hi Everyone, > > > What is the list equivalent to line 12: ncount.sort(reverse=True) > > > count = dict() > fname = raw_input("Enter file name: ")# > handle = open (fname, 'r')# > for line in handle: > if line.startswith("From "): > address = line.split()[5] > line = line.rstrip() > count[address] = count.get(address, 0) + 1 > > for key,val in count.items(): > ncount = (key,val) > ncount.sort(reverse=True) > print key,val > > > Error message, reads: AttributeError, line 12, below : 'tuple' object has no > attribute 'sort' > > Raw data code, available at http://tinyurl.com/ob89r9p > Embedded data code, available at http://tinyurl.com/qhm4ppq > Visualization URL link, available at http://tinyurl.com/ozzmffy > > > Regards, > Hal > -- > https://mail.python.org/mailman/listinfo/python-list -- ---------------------------------------------- LeƓnidas S. Barbosa (Kirotawa) blog: corecode.wordpress.com -- https://mail.python.org/mailman/listinfo/python-list