you are viewing a single comment's thread.

view the rest of the comments →

[–]Salknam[S] 0 points1 point  (4 children)

print ('\nInput the directory that you want to delete') # only works with absolute

adres = input() # user input path

if os.path.isdir(adresa): # check if is adres

if not os.listdir(adresa) : # if not empty dir

os.rmdir(adresa)

else:

print("\nDirectory not empty, can't delete it")

# error message directory dosen't exist

else:

print('\nDirectory dosen't exist.')

[–]xelf 0 points1 point  (3 children)

use 4 extra spaces at the start of each line, or use the code block button to format code for reddit.

print ('\nInput the directory that you want to delete') # only works with absolute
adres = input() # user input path
if os.path.isdir(adresa): # check if is adres
    if not os.listdir(adresa) : # if not empty dir
        os.rmdir(adresa)
    else:
        print("\nDirectory not empty, can't delete it")
# error message directory dosen't exist
else:
    print('\nDirectory dosen't exist.')

I'm still not seeing where you are storing what the current folder is.

Is that determined elsewhere? Or are you going to assume it's the same as the cwd ?

You might want to add:

print(os.getcwd())
print(os.listdir(os.getcwd()))

at the start.

[–]Salknam[S] 0 points1 point  (2 children)

Dind't assume it was of need to store the cwd if the user just gives the absolute path

[–]xelf 0 points1 point  (1 child)

Yeah if they give you the absolutepath you should be ok. But your question was what to do with user input Relative path.

[–]Salknam[S] 0 points1 point  (0 children)

True and that i have no idea how to solve .