Skip to content

Instantly share code, notes, and snippets.

@youknowcast
Created July 6, 2019 00:54
Show Gist options
  • Save youknowcast/131296b3c3d341714075bbd10fa65454 to your computer and use it in GitHub Desktop.
Save youknowcast/131296b3c3d341714075bbd10fa65454 to your computer and use it in GitHub Desktop.
Q3-2
def mask_3rd(word):
if len(word) < 3:
return word
else:
ch = word[2]
ret = word.replace(ch, "*")
return "".join([ret[:2], ch, ret[3:]])
print(mask_3rd('logging'))
print(mask_3rd('apple'))
print(mask_3rd('orange'))
print(mask_3rd('gooooogle'))
print(mask_3rd('i'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment