Trying to create function called parseExtension that takes a file name as a string parameter and returns the file extension.
Going to ask users to input a filename ie. Python.exe then print the file extension.
I tried to split the text and a number of issues for me so far. I'm using 2.7.
i.e. Please enter your filename: Python.exe
Your file extension is an: exe
Ya i seen that ty, I wasnt using the gui and needed it with a function but I did see that before and found out how I did it is like this:
if filename.strip('any')[-3:]: #Check if the filename no matter what it is report back 3 spots from the period.
print filename[-3:] #Print the filename 3 spaces from 0 to the right.
filename.split('.') #Split the filename from the 'period'.
but the os command is undefined isnt it? i dont understand the import os because I need it to take any user input. All the examples set filename = something then prints it. I need it to take user input no matter what it is and seperate the extension. Even if it kgjbdkjbdkjbdf.exe or python.exe.