mardi 28 juillet 2020

Python one line if else statement SyntaxError, the error is at the "else", what can be the problem?

def censor_string(txt, lst, char):
    return " ".join([char*len(i) for i in txt.split() if i in lst else i])
print(censor_string("The cow jumped over the moon.", ["cow", "over"], "*"))

Aucun commentaire:

Enregistrer un commentaire