Python function help, does someone can tell me why it doesent work?

Question:

my task is to write a python program removes all characters or strings from a string (text)
specified in a list (strings_list). I got it like this but this doesen’t work. Anybody can tell me what i got wrong or did I use a wrong function?
Thanks!!

def remove_strings(text, strings_list):
    for strings_list in remove_strings:
        strings_list.remove()
        
        text_cleaned = remove_strings("yes, no, maybe..",
                                      ["yes", ","])
    return text_cleaned
    print(text_cleaned)
Asked By: FeliciaProgramm

||

Answers:


def removechar(text, strings_list):
    newstrings = []
    for i in strings_list:
            
        if text in i:
            newtext = ""
            newtext = i
            newtext = newtext.replace(text, "")
            newstrings.append(newtext)
        else:
            newstrings.append(i)

    print(newstrings)
    return(newstrings)

also, .remove() isnt a function, you would have to use .replace(text, "") instead

Answered By: Anton Chernyshov
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.