[Tutor] Dictionary Issue

Alan Gauld alan.gauld at btinternet.com
Thu Aug 6 00:55:34 CEST 2015


On 05/08/15 23:36, Clayton Kirkwood wrote:

> It looks like the problem is with count=dict()
> Should be count=dict{}
>
> I may be wrong - U'm still a neophyte.

Yes, you're wrong! :-)

the correct form is as shown

count = dict()

Its calling the type operation which looks like
any other function and uses ().

The more common way to create an empty dictionary
is to use {} alone, like:

count = {}

Although count is probably a bad name choice since
collections usually merit a plural name, eg counts

But the OP's problems lie earlier in the code,
as Mark has suggested.

-- 
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




More information about the Tutor mailing list