0

For the code below I am not replacing anything in the old txt. I am expecting it returns: "Where did my vowels go?"

def uncensor(txt, vowels):
    c = 0
    for a in txt:
        if a == '*':
            txt.replace('*', vowels[c], 1)
            c=c+1
    return txt

uncensor("Wh*r* d*d my v*w*ls g*?", "eeioeo")

However, I can replace letter if I do:

txt = 'Wh*r* d*d my v*w*ls g*?'
vowels = 'eeioeo'
txt.replace('*', vowels[0],1)

Where am I doing wrong?

John
  • 331
  • 2
  • 11

1 Answers1

1

You need to return the result:

result = txt.replace('*', vowels[c], 1)
kalzso
  • 502
  • 2
  • 6
  • 27