1

I am new to Python and need some help with the following codes. The mission is to replace all "bad" symbols and characters with empty strings "".

test_data = ["1913-1923","(1951)", "1994", "1934", "c. 1915", "1995", "(1988)", "2002", "1957-1959","c. 1955.", "c. 1970's", "C. 1990-1999"]

bad_chars = ["(",")","c","C",".","s","'", " "]

This is what I thought would work:

def func1(list1, tobereplaced):
    for x in tobereplaced:
        for i in list1:
            i = i.replace(x,'')
    return list1

The function made no changes to the list. Could someone please explain to me what went wrong? Many many thanks!

Yomiko Q
  • 11
  • 2

0 Answers0