Hello all, I am new to python and in need of some aide. I am going through some Homework and am completely stumped and unable to find answers in any tutorials that are in plain enough english that I can understand.
my code is so far as followed:
Thus far the code will run and shows what is explained in the question, however; if the file extension was for example a .jpeg it would not work properly.
question for this question is as followed:
1. The “\” in Windows file paths are represented by “\\” or “/” in Python. Create a FileInfo.py and create two functions: GetFileExtensio n(fullFileName) and GetBaseFileName (fullFileName). Given “C:/MyFolder/Docs/Notes.txt”, GetFileExtensio n will return “.txt” and GetBaseName will return “C:/MyFolder/Docs/Notes”. At the top of FileInfo.py, write the code for these two functions. At the bottom of FileInfo.py, write calls to both of these functions using “C:/MyFolder/Docs/Notes.txt” as the argument.
HINTS: You will be using slicing and the len() function to perform this task.
any aide would be greatly appreciated.
my code is so far as followed:
Code:
def GetFileExtension(fullFileName):
print fullFileName[-4:]
def GetBaseName(fullFileName):
print fullFileName[:-4]
GetFileExtension("C:/MyFolder/Docs/Notes.txt")
GetBaseName("C:/MyFolder/Docs/Notes.txt")
question for this question is as followed:
1. The “\” in Windows file paths are represented by “\\” or “/” in Python. Create a FileInfo.py and create two functions: GetFileExtensio n(fullFileName) and GetBaseFileName (fullFileName). Given “C:/MyFolder/Docs/Notes.txt”, GetFileExtensio n will return “.txt” and GetBaseName will return “C:/MyFolder/Docs/Notes”. At the top of FileInfo.py, write the code for these two functions. At the bottom of FileInfo.py, write calls to both of these functions using “C:/MyFolder/Docs/Notes.txt” as the argument.
HINTS: You will be using slicing and the len() function to perform this task.
any aide would be greatly appreciated.
Comment