info_outline

Solutions will be available when this assignment is resolved, or after a few failing attempts.

First Half

The function first_half returns the "first" half of a string (pretty obvious, right?). So, if you invoke first_half('abcdef') you should get 'abc' as a result. But what happens if the string has an odd number of characters like the following example? first_half('abcXdef') (7 characters). In that case, first_half should include the character in the middle; the result should be: abcX.

For this assignment you'll have to check the length of the string and handle the even/odd cases.

Make sure you return your result!

Test Cases

test first half with even length string - Run Test

def test_first_half_with_even_length_string():
    assert first_half('abcdef') == 'abc'

test first half with odd length string - Run Test

def test_first_half_with_odd_length_string():
    assert first_half('abcXdef') == 'abcX'
def first_half(a_string): pass