Path: csiph.com!goblin1!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.011 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'method.': 0.05; 'cc:addr :python-list': 0.09; 'fname': 0.09; 'tuple': 0.09; 'everyone,': 0.15; 'handle:': 0.16; 'wrote:': 0.16; 'attribute': 0.18; 'creates': 0.18; '2015': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'aug': 0.20; 'assign': 0.22; 'tuples': 0.22; 'cc:no real name:2**0': 0.22; 'code,': 0.23; 'header:In- Reply-To:1': 0.24; 'skip:- 40': 0.25; 'error': 0.27; 'equivalent': 0.27; 'raw': 0.27; 'message-id:@mail.gmail.com': 0.27; 'correct': 0.28; 'be:': 0.29; 'print': 0.30; 'url:mailman': 0.30; 'blog:': 0.30; 'embedded': 0.32; 'url:python': 0.33; 'open': 0.33; 'url:listinfo': 0.34; 'tue,': 0.34; 'file': 0.34; 'handle': 0.34; 'list': 0.34; 'received:google.com': 0.35; 'url:org': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; '12,': 0.37; 'list.': 0.37; 'data': 0.39; 'url:mail': 0.40; 'address': 0.61; 'subject:skip:A 10': 0.63; 'url:tinyurl': 0.67; '12:': 0.84; 'dict()': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; bh=jwObVdmO7XC116NV+0shTgljv5NcV9+Ncg8zt5hZl44=; b=hHNSUte5J2p6coVVvi1Uq+K4PtWqS96haQD2tIXZ78EvP1cjabT5rJCZKDt5FgN6SC Jq0YjeEKmyT0BhCDbyhsx1C9YhH9BfRKqGsPHcviDpbhD9rIJ5f2RlBMxVwxJ4yIAhY5 Xss/50pawoi8T6ArZQsORh+HOwn1cVaKkjg4QVuNOcRBRpYC9UlzJ0ldA4KjdOqN1dEG rw5XwbCVSWcOr0jX6dnLTBcs6Ucu2q9YPpwPYHhGL9mYOQ0dP4OtzWlBhrX8u0eIo7Dj Ha8cVxGoyawZEEN1HJG+YHKceuvxNiwn7Pn6BCge9f0JwwVqPRE3dREVMX44OpNfF1VC X0kw== X-Received: by 10.50.88.8 with SMTP id bc8mr22375434igb.46.1439338620028; Tue, 11 Aug 2015 17:17:00 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <0baa3bd5-9f80-4d4e-9367-84e2a32d8c70@googlegroups.com> References: <0baa3bd5-9f80-4d4e-9367-84e2a32d8c70@googlegroups.com> From: leo kirotawa Date: Tue, 11 Aug 2015 21:16:40 -0300 Subject: Re: AttributeError To: Ltc Hotspot Cc: python-list@python.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 46 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1439338622 news.xs4all.nl 2847 [2001:888:2000:d::a6]:44493 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:95264 assign using () creates tuple not a list. Tuples have not .sort() method. correct would be: ncount =3D [key,val] On Tue, Aug 11, 2015 at 9:01 PM, Ltc Hotspot wrote: > Hi Everyone, > > > What is the list equivalent to line 12: ncount.sort(reverse=3DTrue) > > > count =3D dict() > fname =3D raw_input("Enter file name: ")# > handle =3D open (fname, 'r')# > for line in handle: > if line.startswith("From "): > address =3D line.split()[5] > line =3D line.rstrip() > count[address] =3D count.get(address, 0) + 1 > > for key,val in count.items(): > ncount =3D (key,val) > ncount.sort(reverse=3DTrue) > 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 --=20 ---------------------------------------------- Le=C3=B4nidas S. Barbosa (Kirotawa) blog: corecode.wordpress.com