How can i remove every character before a specific character in a tuple of lists of strings in Python

I have a tuple of lists of strings that looks like this

myList = [''], [''], ['']

and i need to remove the last "-" character and every character before that.

>Solution :

result = []
for url in myList:

Outputs :

['12', '14', '1']

Explanation :

url is a list that has a single element, url[0]. Applying split('-') on that string split the string into a list of strings that were separated with ‘-‘.
ie : ''.split('-') -> ['', 'video', '12'].
Finally list[-1] gives the last element of list

Leave a Reply