[Tutor] Fwd: Fwd: Re: Output 'Strings' to directory

Alan Gauld alan.gauld at btinternet.com
Tue Sep 9 18:57:11 CEST 2014


> From: Felisha Lawrence <felisha.lawrence at gmail.com>
> Date: Tue, Sep 9, 2014 at 8:53 AM
> Subject: Re: [Tutor] Fwd: Re: Output 'Strings' to directory
> To: Danny Yoo <dyoo at hashcollision.org>
>
>
> Also,
> I had this code working
>
> import os
>
> path = '/Users/felishalawrence/testswps/vol1'
> for file in os.listdir(path):
>          newFile = file[:file.index("v")]+"v20"
>
>          print newFile
> and now I am getting this error
>
> ValueError: substring not found
>
> I did not change anything

Have you checked that no new files have been created - possibly by your 
code, that don't conform to your expected naming style?

Try putting a 'print file'  before the name modification to see what the 
name that causes the error looks like.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.flickr.com/photos/alangauldphotos



More information about the Tutor mailing list