13.9k views
4 votes
In Python

Assign number_segments with phone_number split by the hyphens.

Sample output with input: '977-555-3221'
Area code: 977

User Lundin
by
6.6k points

1 Answer

1 vote

Answer:

phone_number = input()

number_segments = phone_number.split('-')

area_code = number_segments[0]

print('Area code:', area_code)

Explanation: The answer above was correct but had incorrect naming for the Zybooks version

User Boris Pawlowski
by
6.8k points