Jan-01-2020, 12:00 PM
Hi,
I have below code to split the list and get the last element as the file name.
but when I access the last element after splitting, its is not giving me the last element.
my_file[:-1]
Out[25]: "['', 'D', 'Mekala_Backupdata', 'PythonCodes"
I have below code to split the list and get the last element as the file name.
but when I access the last element after splitting, its is not giving me the last element.
post_fix = ['D/Raj_Data/PythonCodes','/C/Viru_Data/PythonCodes'] for i in range(len(post_fix)): tmp = str((post_fix[i])[:-1]) #print(tmp) print((str(post_fix[i].split('/')))[:-1])when I print as below:
my_file[:-1]
Out[25]: "['', 'D', 'Mekala_Backupdata', 'PythonCodes"