I have several scripts that take as input a directory name, and my program creates files in those directories. Sometimes I want to take the basename of a directory given to the
To deal with your "trailing slash" issue (and other issues!), sanitise user input with os.path.normpath().
os.path.normpath()
To build paths, use os.path.join()
os.path.join()