0
string = ['Japanese', 'Painting Books', 'Management Textbooks', 'science book (Books)']
 
strp_l=[]
for i in string:
  a=i.strip('(Books)').strip('Textbooks').strip('Books')
  strp_l.append(a)
print(strp_l)

I got output as

['Japan', 'Painting ', 'Management ', 'science book ']

but I tried to get output like

['Japanese', 'Painting ', 'Management ', 'science book ']
Barmar
  • 741,623
  • 53
  • 500
  • 612
  • 1
    have you read the documentation of `strip()`? – Barmar Nov 10 '20 at 02:19
  • The characters inside the brackets are going to be used one at a time and stripped. So `Japanese` will get stripped to `Japan` because of `Textbooks` The characters `e` and `s` are part of `Japanese` so it strips them out. Similarly for all other items. – Joe Ferndz Nov 10 '20 at 02:25

0 Answers0