[Tutor] String within a string solution (newbie question)

Wish Dokta glenuk at gmail.com
Thu Oct 27 08:37:31 EDT 2016


Hello Alan,

Thank you for the reply.

I have actually fixed that bug. If you are bored or for some other reason
would like to assist a newbro my code is here:

main: http://pastebin.com/LgbeywiB
functions: http://pastebin.com/vU7zzJKe

I'd be very grateful for any feedback on improvements to the code or how I
am coding in general. I'd be particularly interested in a better data
structure to use to store the directories and their sizes.

Many thanks,
Glen

On 26 October 2016 at 19:34, Alan Gauld via Tutor <tutor at python.org> wrote:

> On 26/10/16 19:06, Wish Dokta wrote:
>
> > folders with a drive/directory. To do this I am storing each directory
> in a
> > dict as the key, with the value being the sum of the size of all files in
> > that directories (but not directories).
> >
> > For example:
> >
> > for "C:\\docs\\code" in key:
> >
> > Which works fine and will return "C:\\docs\\code" : 20,
> > "C:\\docs\\code\\snippets" : 5, "C:\\docs\\code\\python" : 10 = (35)
> >
> > However it fails when I try to calculate the size of a directory such as
> > "C:\\docs", as it also returns "C:\\docs123".
> >
> > I'd be very grateful if anyone could offer any advice on how to correct
> > this.
>
> We can't guess what your code looks like, you need to show us.
> Post the code and we can maybe help.
>
> --
> 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