'''
==================================================================
How to Remove the Last Component of a String
How to Move Back Up a Hierarchy with a Given Pathway/File Address
==================================================================
Source: https:
Note: If you are wanting to remove the last component of a string
but it has forward slashes rather than backslashes, you will
want to use ".normpath" instead of ".dirname"
'''
import os.path
#Asks user for desired file pathway
inpDirectoryPath = input("What is your directory path? Enter here: ")
print("\n\nYour given pathfile is " + inpDirectoryPath + ". Now we will delete the last component of it.")
#this removes the last component of the given pathway.
deletedPathComponent = os.path.dirname(inpDirectoryPath)
print("\n\nThe path now looks like this: " + deletedPathComponent)
'''
Output:
What is your directory path? Enter here: C:\Users\Justin\Documents\Homework\Calculus
Your given pathfile is: C:\Users\Justin\Documents\Homework\Calculus. Now we will delete the last component of it.
The path now looks like this: C:\Users\Justin\Documents\Homework
'''