580 total contributions
The .dirname() method returns the part of the pathname ranging from the start to the last forward-slash.
.dirname()
os.path.dirname(path_string)
The path_string must be a string or byte data type.
path_string
The following example showcases the .dirname() method using a Codecademy URL:
usVisit uscodeHide codeCodeOutputHide outputHide outputLoading...Run