os.path.isdir() checks if the path exists and is a directory and returns TRUE for the case.
Similarly, os.path.isfile() checks if the path exists and is a file and returns TRUE for the case.
And, os.path.exists() checks if the path exists and doesn’t care if the path points to a file or a directory and returns TRUE in either of the cases.