SHARE
TWEET

Untitled

a guest Jul 17th, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # -*- coding: utf-8 -*-
  2. """
  3. Created on Sat Jul  6 09:36:27 2019
  4.  
  5. @author: Jiang.Lijin
  6. """
  7.  
  8. def mask_3rd(s):
  9.     #3以下そのまま返す
  10.     if len(s) <= 3:
  11.         return s
  12.    
  13.     #置換
  14.     ret = s.replace(s[2], "*")
  15.     #返す文字列結合
  16.     return ret[:2] + s[2] + ret[3:]
  17.    
  18. print(mask_3rd("logging"))
  19. print(mask_3rd("apple"))
  20. print(mask_3rd("orange"))
  21. print(mask_3rd("gooooogle"))
  22. print(mask_3rd("i"))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top