I have a list of URLs, and I am trying to remove the trailing '/' from all URLs in the list. I have tried all of these variations with no error message, but no removal of the /:
for link in url_list:
if link.endswith('/'):
url_list.append(link[:-1])
for link in url_list:
if link.endswith('/'):
link = link[:-1]
for link in url_list:
link = link[:-1] if link.endswith('/') else link
After running these codes I print(url_list)
and nothing has changed.