I am attempting to write a method that replaces every occurrence of a letter after the first as a "*" instead of the letter. Examples: "babble" yields "ba**le" "that" yields "tha*"
My code seems to be having an issue with the replace function while looping and I can't quite figure out why.
def fix_start(s):
if len(s) < 2:
s = ""
else:
for i in s:
if i == s[0]:
if s[0]:
continue
s.replace(s[i], "*")
i += i
print(s)
Aucun commentaire:
Enregistrer un commentaire