Created
April 1, 2019 05:50
-
-
Save srafay/cf4fe0e2da5547d7fdaa517e4a4a6dce to your computer and use it in GitHub Desktop.
Function for masking middle elements in a string
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def mask_middle(text): | |
text = str(text) | |
if len(text) > 2: | |
return text[0] + "*" * (len(text) - 2) + text[len(text) - 1] | |
return "*" * len(text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment