189k views
5 votes
Assign number_segments with phone_number split by the hyphens.

a) number_segments = phone_number.split('-')
b) number_segments = phone_number.split(',')
c) number_segments = phone_number.split('_')
d) number_segments = phone_number.split('.')

User Mdd
by
8.0k points

1 Answer

5 votes

Final answer:

The correct way to split a phone number into segments by hyphens in a string is option a, which uses the split method with a hyphen as the delimiter.

Step-by-step explanation:

The question pertains to how to split a string in programming, particularly when dealing with a phone number. When splitting a string by a certain delimiter, you must use a method that specifies the exact character you want to use to split the string. Since traditional phone numbers are split by hyphens, the correct way to separate the segments would be:number_segments = phone_number.split('-')

This means that the correct answer to the question would be option a.

User NuAlphaMan
by
8.2k points