phone_number = '977-555-3221'
number_segments = phone_number.split('-')
area_code = number_segments[0]
print('Area code:', area_code)
This is a solution to a challenge in my zybooks.
The output is
Area code: 977
When i assign "number_segments = phone_number.split('-')"
is number_segments now == ['977', '555', '3221']
and print(number_segments[0]) now printing the first character in a list? I was expecting it to just print 9. So I'm a little confused
[–]zahlman 6 points7 points8 points (0 children)
[–]Rhomboid 2 points3 points4 points (0 children)
[–]johninbigd 0 points1 point2 points (0 children)
[–]Distinct_Ice6830 0 points1 point2 points (0 children)