Redact a Contact Number

Keep only decimal digits from the phone string using str.isdecimal(), then mask every digit except the final four with *. Preserve the final digits exactly, including Unicode decimal digits. Numbers with four or fewer digits are unchanged; text with no digits returns an empty string.

Difficulty: beginner

Examples

  • ["+977 (98) 123-4567"]"********4567"

Your solution

Python

Results

Python starts when you run or submit this challenge.

Back to Lesson