AttributeError

MRAB python at mrabarnett.plus.com
Wed Aug 12 13:24:43 EDT 2015


On 2015-08-12 17:57, Ltc Hotspot wrote:
> MRAB,
>
> I ran the code, and the output:
>
>
> Raw data code:
> handle = """From stephen.marquard at uct.ac.za Sat Jan  5 09:14:16 2008
> >From louis at 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 <module>
> ()
>       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?




More information about the Python-list mailing list