[I just want to keep the years and not the numbers in present in the bracket.][1]
[This is my current output. I want to strip the data which is in the bracket and do this for all the data present in the list till the end][2]
[I just want to keep the years and not the numbers in present in the bracket.][1]
[This is my current output. I want to strip the data which is in the bracket and do this for all the data present in the list till the end][2]
We can do that by using regex expressions.
import re # Import
reg = "[\(\[].*?[\)\]]" # Regex Expression
stripped_title = [re.sub(reg, "", i) for i in title]
print(stripped_title)
##2nd Case
stripped_title = [re.search('\d+', i).group(0) for i in title]
print(stripped_title)
Use .split()
function.
striped_titles = titles.split(",")
So, now you can access each element from new list striped_titles