Kodewick
Start learning →
Basic←→0 / 100

Hide the phone number

#034BasicStrings3 min

A delivery slip should not show the whole phone number. Write hide_phone(phone) to turn every digit except the last 4 into *. Numbers have at least 4 digits; one with exactly 4 comes back as it is.

Examples
hide_phone("13812345678")→'*******5678'
hide_phone("5550199")→'***0199'
main.py
def hide_phone(phone):
    # your code here: as many "*" as the digits in front,
    # then the last 4 digits
    return phone
Ctrl + Enter runs too
Result

Run tries the examples. When they look right, Submit.