On the practice functions


#1

def censor(text, word):
words = text.split()
result = ‘’
stars = ‘*’ * len(word)
count = 0
for i in words:
if i == word:
words[count] = stars
count += 1
result =’ '.join(words)

return result

print censor(“this hack is wack hack”, “hack”)

can someone tell me what "words[count] = stars " does in the code
thanks.


#2

count is a running value that starts at zero and grows by 1 with each new word being iterated.

words[count]

is the word at the index, count, which is then replaced with a string of stars of the same length.

words[count] = stars