[Tutor] Dictionary Issue

Ltc Hotspot ltc.hotspot at gmail.com
Fri Aug 7 20:18:16 CEST 2015


Alan,

I want to find the max val ,  keys and values are defined on line 10:
for kee, val in count.items():

Then,  maxval determines the max value on line 11:
if val > maxval:

right, view a copy of the revised code at
http://tinyurl.com/nvzdw8k

Question1: are these assumptions true, above?

Question2: dict maps strings into keys and values?


Hal



On Thu, Aug 6, 2015 at 11:35 PM, Alan Gauld <alan.gauld at btinternet.com>
wrote:

> On 07/08/15 01:15, Ltc Hotspot wrote:
>
>> Question1: How type of argument should I use for dict, i.e.,user argument
>> or list argument.
>>
>> Read captured traceback:
>>
>> TypeError
>> Traceback (most recent call last)
>> C:\Users\vm\Desktop\apps\docs\Python\assignment_9_4_26.py in <module>()
>>        1 fname = raw_input("Enter file name: ")
>>        2 handle = open (fname, 'r')
>> ----> 3 count = dict.keys()
>>        4 for line in handle:
>>        5     if line.startswith("From: "):
>>
>
>
> You appear to be making random changes to your code
> for no good reason.
>
> I will not make any further suggestions until you
> start to explain your thinking.
>
> What do you think the line
>
> count = dict.keys()
>
> will do? Why do you want to do that?
> How will it help you solve your problem?
>
> --
> Alan G
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
> http://www.amazon.com/author/alan_gauld
> Follow my photo-blog on Flickr at:
> http://www.flickr.com/photos/alangauldphotos
>
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>


More information about the Tutor mailing list