[Tutor] Alice_in_wonderland Question

Alan Gauld alan.gauld at btinternet.com
Tue May 6 19:44:58 CEST 2014


On 05/05/14 04:13, Jake Blank wrote:

> I did have one more question though.
>
> import os
> from wordtools import extract_words
>
> source_filepath=input("Enter the path to the source file:")
> dest_filepath =input("Enter the path to the destination file:")
>
> I'm wondering how I can make it so the program can tell if the
> source/dest_filepath the user entered is actually a program on the computer.

Do you really mean is it a program? - ie an executable file? Or do you 
just want to know if the file (any kind of file) exists?

There are ways to do what you want but you need to be much more specific.


> Also i have to ask the user if they would like to "process another
> file(Y/N)?" and I'm not sure where to put that.

You need a loop. It will look something like(pseudo code)

while True:
    you existing copy code here
    ask the user if they want to do more
    if they don't:
       break  # exit the loop

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