Mask a card number

Easyreplaceslicingstring repetition· 10 XP

Receipts should only show the last four digits of a payment card. Card numbers arrive with or without spaces between the groups of digits.

Write a function mask_card(number) that removes any spaces, then replaces every digit except the last four with *.

How it's checked

Your code runs, then the check below runs and its printed output is compared with ours.

  • mask_card("4111 2222 3333 4444") returns "************4444"
def mask_card(number):
    ...