On 02/06/15 00:42, Alan Gauld wrote:
forwordintext: ifwordnot inwords: words[word] =1 else: words[word] +=1Look into the setdefault() method of dictionaries. It can replace the if/else above.
On reflection, the get() method might be even more useful. -- 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 - [email protected] To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
