DESCRIPTION:
Usually when you buy something, you're asked whether your credit card number, phone number or answer to your most secret question is still correct. However, since someone could look over your shoulder, you don't want that shown on your screen. Instead, we mask it.
Your task is to write a function maskify, which changes all but the last four characters into '#'.
Examples
"4556364607935616" --> "############5616"
"64607935616" --> "#######5616"
"1" --> "1"
"" --> ""
// "What was the name of your first pet?"
"Skippy" --> "##ippy"
"Nananananananananananananananana Batman!"
-->
"####################################man!"
def maskify(cc):
return "#"*(len(cc)-4) + (cc[len(cc)-4:]) if len(cc)>=4 else cc
'알고리즘 문제 > CodeWar' 카테고리의 다른 글
Sum of Numbers (1) | 2022.10.04 |
---|---|
Your order, please (0) | 2022.10.04 |
Jaden Casing Strings (0) | 2022.10.04 |
Mumbling (0) | 2022.10.04 |
Reverse every other word in the string (0) | 2022.10.04 |