curriculum/challenges/english/blocks/daily-coding-challenges-python/68cae5b538ff798bbd4da006.md
Given a string of credit card numbers, return a masked version of it using the following constraints:
0-9), with all sets being separated by a single space, or a single hyphen (-).*).For example, given "4012-8888-8888-1881" return "****-****-****-1881".
mask("4012-8888-8888-1881") should return "****-****-****-1881".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(mask("4012-8888-8888-1881"), "****-****-****-1881")`)
}})
mask("5105 1051 0510 5100") should return "**** **** **** 5100".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(mask("5105 1051 0510 5100"), "**** **** **** 5100")`)
}})
mask("6011 1111 1111 1117") should return "**** **** **** 1117".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(mask("6011 1111 1111 1117"), "**** **** **** 1117")`)
}})
mask("2223-0000-4845-0010") should return "****-****-****-0010".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(mask("2223-0000-4845-0010"), "****-****-****-0010")`)
}})
def mask(card):
return card
def mask(card):
if '-' in card:
split = card.split('-')
return f"****-****-****-{split[3]}"
else:
split = card.split(' ')
return f"**** **** **** {split[3]}"