-3

[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]

[1]https://i.stack.imgur.com/4Q9Wg.png

[2]https://i.stack.imgur.com/SOVQO.png

Mohit P
  • 1
  • 1

2 Answers2

0

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)
Pavan Suvarna
  • 486
  • 3
  • 13
0

Use .split() function.

striped_titles = titles.split(",")

So, now you can access each element from new list striped_titles

Jff
  • 91
  • 1
  • 8