1

I am trying to design a block of code that checks if a user inputted directory exists, prints if it does, and if it does not.

 import os

 foldername = raw_input ("Please enter the name of your desired folder: ")

 if os.path.exists(foldername):
      print "Yes, your folder exists!"
 else:
      print "Please re-enter your folder directory as it does not exist."

The abov is what I have, but it consistently outputs that the directory does not exists, despite me knowing that it does.

Insights?

1
  • 2
    The issue is probably related to path separators (/ or \ ), or with an incomplete file path. However, this is pure python, and should be asked on StackOverflow :)
    – Erica
    Feb 26, 2015 at 18:14

0

Browse other questions tagged or ask your own question.