So I have a python list (called lst in the snippet below) of urls.
lst2 = 
for i in lst:
lst = [url1, url2, ...], your current code is very close to working optimally.
The last line of the code
lst2.append(i.split('/')][-1]) is where the problems lie.
i you are essentially getting the first character of the
i string (since the
i derives from the strings inside
lst), and then splitting it based on
/, which would not work. Then you have an error with the lone
] after the
So, to fix this code, here is what you would do.
lst2 =  for i in lst: lst2.append(i.split('/')[-1])
and then, printing
lst2 would give
['file.zip', 'file1.zip', ...]
which is your desired output.
i in lst is getting every item inside the
lst list, which are strings. Then, inside the loop, the string
i is being split according to the
/ inside it, which generates another array. But you want the final part of that string, hence the final item in the array, which can be accessed using