Skip to content

Commit

Permalink
Update my_code.py
Browse files Browse the repository at this point in the history
  • Loading branch information
jameshowison authored Apr 3, 2024
1 parent 60674b4 commit 43cd18d
Showing 1 changed file with 0 additions and 8 deletions.
8 changes: 0 additions & 8 deletions my_code.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import pytest

def fix_phone_num(phone_num_to_fix):
# can only handle numbers that are exactly 10 digits long
if (len(phone_num_to_fix) != 10):
raise ValueError("Can only format numbers that are exactly 10 digits long")

# given "5125558823". Split the parts, then recombine and return
area_code = phone_num_to_fix[0:3] # 512 (first three digits)
three_part = phone_num_to_fix[3:6] # 555 (next three digits)
Expand All @@ -16,7 +12,3 @@ def fix_phone_num(phone_num_to_fix):

def test_fix_phone_num():
assert fix_phone_num("5125558823") == '(512) 555 8823'

# Now check that a too short string gives a ValueError
with pytest.raises(ValueError):
fix_phone_num("51")

0 comments on commit 43cd18d

Please sign in to comment.