You are going to be given a word. Your job is to return the middle character of the word. If the word’s length is odd, return the middle character. If the word’s length is even, return the middle 2 characters.
Kata.getMiddle("test") should return "es" Kata.getMiddle("testing") should return "t" Kata.getMiddle("middle") should return "dd" Kata.getMiddle("A") should return "A"
def get_middle(s): elen = len(s)/2 olen = int(round(len(s)/2)) return s[(elen-1):(elen+1)] if len(s)%2 == 0 else s[olen:olen+1]
def get_middle(s): return s[(len(s)-1)/2:len(s)/2+1]