I have tried this code but it didnt work how to remove the path from String.help me to remove the path of directories from the string
string=""
count=0
for file in glob.glob(r'G:\\songs\\My Fav\\*'):
string=string+"{}. {}\n".format(count,file)
count+=1
string=string.replace("G:\\songs\\My Fav\\","")
print(string)
OUTPUT for above code is :
0. G:\\songs\\My Fav\0001.mp3
1. G:\\songs\\My Fav\0002.mp3
2. G:\\songs\\My Fav\0003.mp3
3. G:\\songs\\My Fav\0004.mp3
4. G:\\songs\\My Fav\0005.mp3
But i need output without the path, like this below
0. 0001.mp3
1. 0002.mp3
2. 0003.mp3
string=string.replace("G:\\songs\\My Fav\","")
and this above line i have tried shows error