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.

#Examples:
~~~if-not:bf
```
Kata.getMiddle("test") should return "es"

Kata.getMiddle("testing") should return "t"

Kata.getMiddle("middle") should return "dd"

Kata.getMiddle("A") should return "A"

```
~~~
~~~if:bf
```
runBF("test\0") should return "es"

runBF("testing\0") should return "t"

runBF("middle\0") should return "dd"

runBF("A\0") should return "A"

```
~~~

#Input

A word (string) of length `0 < str < 1000` (In javascript you may get slightly more than 1000 in some test cases due to an error in the test cases). You do not need to test for this. This is only here to tell you that you do not need to worry about your solution timing out.


#Output

The middle character(s) of the word represented as a string.

Source: codewars | Difficulty: EASY
Tags: String algorithms

Fundamentals

Starter code: def get_middle(s):
	

Solutions:
def get_middle(s):
	return s[(len(s) - 1) // 2:len(s) // 2 + 1]


def get_middle(s):
	(index, odd) = divmod(len(s), 2)
	return s[index] if odd else s[index - 1:index + 1]


import math

def get_middle(s):
	x = len(s)
	y = int(x / 2)
	if x % 2 == 0:
		return s[y - 1:y + 1]
	else:
		return s[y:y + 1]


def get_middle(s):
	i = (len(s) - 1) // 2
	return s[i:-i] or s


def get_middle(s):
	x = int(len(s) / 2)
	return s[x] if len(s) % 2 != 0 else s[x - 1:x + 1]


def get_middle(s):
	(q, r) = divmod(len(s), 2)
	return s[q - (1 if not r else 0):q + 1]


def get_middle(s):
	if len(s) % 2 == 0:
		iA = int(len(s) / 2 - 1)
		iB = int(len(s) / 2 + 1)
		return s[iA:iB]
	else:
		return s[int(len(s) / 2)]