Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def mask_3rd(s):
- if len(s) < 3:
- print(s)
- else:
- third = s[2]
- second = s[:2]
- fourth = s[3:]
- return second.replace(third, "*") + third + fourth.replace(third, "*")
- print(mask_3rd("logging"))
- print(mask_3rd("apple"))
- print(mask_3rd("orange"))
- print(mask_3rd("gooooogle"))
- print(mask_3rd("i"))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement