13 lines
480 B
Python
13 lines
480 B
Python
def area_code(phone_number):
|
|
""" Given a phone number in the format: 802-555-1212
|
|
extract the first 3 characters and return this as a string
|
|
|
|
:param phone_number: (str) Must be formatted "XXX-XXX-XXXX"
|
|
:return: (str) 3 digit area_code
|
|
"""
|
|
return phone_number[:3]
|
|
|
|
|
|
# Leave this part for easily testing your function
|
|
print('"802-555-1212" area_code returns', area_code("802-555-1212"))
|
|
print('"410-617-3452" area_code returns', area_code("410-617-3452"))
|