Path: csiph.com!eternal-september.org!feeder.eternal-september.org!feeds.phibee-telecom.net!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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'data:': 0.07; 'indicated': 0.07; 'val': 0.07; 'lst': 0.09; 'snippet': 0.09; 'jan': 0.11; 'syntax': 0.13; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'handle:': 0.16; 'last)': 0.16; 'line.split()': 0.16; 'message- id:@mrabarnett.plus.com': 0.16; 'received:192.168.1.4': 0.16; 'wrote:': 0.16; 'attribute': 0.18; 'to:name:python- list@python.org': 0.20; 'trying': 0.22; 'code,': 0.23; '(most': 0.24; 'header:In-Reply-To:1': 0.24; 'sort': 0.25; 'header:User- Agent:1': 0.26; 'raw': 0.27; 'key,': 0.29; 'code:': 0.29; 'print': 0.30; 'sat': 0.33; 'traceback': 0.33; 'open': 0.33; 'file': 0.34; 'handle': 0.34; 'add': 0.34; 'fri': 0.35; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'data': 0.39; 'received:192': 0.39; 'to:addr:python.org': 0.40; 'subject:skip:A 10': 0.63; 'hours': 0.65; '>from': 0.76; '--->': 0.84; 'dict()': 0.84 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.1 cv=CvRCCSMD c=1 sm=1 tr=0 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=0Bzu9jTXAAAA:8 a=EBOSESyhAAAA:8 a=UWU4mQFGWXkA:10 a=IkcTkHD0fZMA:10 a=VaJxpvsTu2mVDiQPnJwA:9 a=QEXdDO2ut3YA:10 X-AUTH: mrabarnett@:2500 Subject: Re: AttributeError References: <0baa3bd5-9f80-4d4e-9367-84e2a32d8c70@googlegroups.com> <55CA92BA.7070905@mrabarnett.plus.com> <103ea014-9bdb-4c37-acd1-cdc64f5f721e@googlegroups.com> <3f132c37-bdb5-4313-9285-69e094392ccf@googlegroups.com> <55CB7823.8010402@mrabarnett.plus.com> To: "python-list@python.org" From: MRAB Date: Wed, 12 Aug 2015 18:24:43 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit 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: 49 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1439400287 news.xs4all.nl 2871 [2001:888:2000:d::a6]:59803 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:95301 On 2015-08-12 17:57, Ltc Hotspot wrote: > MRAB, > > I ran the code, and the output: > > > Raw data code: > handle = """From stephen.marquard@uct.ac.za Sat Jan 5 09:14:16 2008 > >From louis@media.berkeley.edu Fri Jan 4 18:10:48 2008 > """.split("\n") > # Snippet file data: mbox-short.txt > > count = dict() > #fname = raw_input("Enter file name: ")# Add Snippet file > #handle = open (fname, 'r')# Add Snippet file > for line in handle: > if line.startswith("From "): > time = line.split() # Sort time > > hours = list.split(":")[5] # Sort hours > line = line.rstrip() > > count[hours] = count.get(hours, 0) + 1 # counter > > lst = [(val,key) for key,val in count.items()] > > print key, val > > ------------------------------------------------------------------------------------- > Syntax message: > In [45]: %run assignment_10_2_v_06 > > AttributeError > Traceback (most recent call last) > C:\Users\vm\Desktop\apps\docs\Python\week_10\assignment_10_2_v_06.py in > () > 11 time = line.split() # Sort time > 12 > ---> 13 hours = list.split(":")[5] # Sort hours > 14 line = line.rstrip() > 15 > > AttributeError: type object 'list' has no attribute 'split' > > In [46]: Read the indicated line _carefully_. What is it _actually_ trying to split?