I'm trying to split the following code into a separate if statement.
def second_half(s):
return s[len(s)//2 if len(s)%2 == 0 else ((len(s)//2)+1):]
I've already tried doing the following:
def second_half(s):
if len(s) % 2 == 0:
return s[len(s)//2]
else:
return s[((len(s)//2)+1):]
and receive the following output in my doctest (although majority of my other tests passed):
Failed example:
second_half("abcdef")
Expected:
'def'
Got:
'd'
Would appreciate any help. Cheers.