Issue with join in Censor


I get the result [' *** ', ' *** ', ' *** '] instead of '*** *** ***'
any help would be greatly appreciated :slight_smile:

def censor(text, word):
    stringed_text = str(text)
    split_st = stringed_text.split()
    censored_text = []
    for words in split_st:
        if words == word:
    return censored_text

print censor('hey hey hey', 'hey')


you join the list into a string, but you never store the result of this action anywhere


ahhh so i should create another variable that equates to the joined string and return that!


worked perfectly, thanks! :slight_smile:


or you can return the joined string directly by adding the return statement before return, but you understand the issue and solved it :slight_smile:


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.