Trying to understand what I'm doing wrong. My code removes all the spaces when creating the new_text. Replaces the selected word with the '*', but prints everything together.
Sorry if this is a bad question. I'm new and trying to grasp the basics. I've been stuck on this one a couple of days.
def censor(text, word): text = text.split() new_text =  for i in text: if i == word: y = len(i) * '*' new_text += y else: new_text += i return ''.join(new_text) print censor('hey hey hey', 'hey')