Issue with join in Censor


#1


https://www.codecademy.com/courses/python-intermediate-en-rCQKw/1/4?curriculum_id=4f89dab3d788890003000096#


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:
            censored_text.append(('*')*len(word))
        else:
            censored_text.append(words)
    ''.join(censored_text)
    return censored_text

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


#2

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


#3

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


#4

worked perfectly, thanks! :slight_smile:


#5

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:


#6

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