Advertisement
Guest User

Untitled

a guest
Jul 17th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. def mask_3rd(s):
  2. if len(s) < 3:
  3. print(s)
  4. else:
  5. third = s[2]
  6. second = s[:2]
  7. fourth = s[3:]
  8. return second.replace(third, "*") + third + fourth.replace(third, "*")
  9.  
  10. print(mask_3rd("logging"))
  11. print(mask_3rd("apple"))
  12. print(mask_3rd("orange"))
  13. print(mask_3rd("gooooogle"))
  14. print(mask_3rd("i"))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement