Censor-- How could this solution be improved?


Lesson 15, Exercise 10

I'm trying to understand code quality and best practices through these exercises. Below is my solution below, which works-- is there anything others would reccommend for this solution to be more efficient or better (naming, etc.)? I'd love to see other solutions and alternatives as well if others are willing to post. Thanks!

def censor(text, word):
    text = text.split()
    for x in range(len(text)):
         if text[x] == word:
             text[x] = "*" * len(word)
    censoredText = ' '.join(text)
    return censoredText


I can see your future , you're gonna be a great programmer


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