# Palindrome strings

A palindrome is a word, phrase, number, or other sequence of characters which reads the same backward or forward. This includes capital letters, punctuation, and word dividers.

Implement a function that checks if something is a palindrome.

## Examples
```
isPalindrome("anna")   ==> true
isPalindrome("walter") ==> false
isPalindrome(12321)    ==> true
isPalindrome(123456)   ==> false
```

Difficulty: EASY

Starter code:
def is_palindrome(string):
	

Solutions:
def is_palindrome(string):
	return str(string)[::-1] == str(string)


def is_palindrome(string):
	a = []
	for i in str(string):
		a.insert(0, i)
	if list(str(string)) != a:
		return False
	else:
		return True


def is_palindrome(string):
	string = str(string)
	return True if string[:len(string) // 2] in string[len(string) // 2:][::-1] else False


def is_palindrome(s):
	s = str(s).lower()
	return s == s[::-1]


def is_palindrome(val):
	s = str(val)
	half_len = len(s) >> 1
	return s[:half_len] == s[::-1][:half_len]


def is_palindrome(s):
	if isinstance(s, int):
		digits = []
		while s:
			(s, r) = divmod(s, 10)
			digits.append(r)
		s = digits
	return all((s[l] == s[r] for (l, r) in enumerate(range(len(s) - 1, len(s) // 2 - 1, -1))))


def is_palindrome(string):
	s = str(string)
	if len(s) < 1:
		return True
	elif s[0] == s[-1]:
		return is_palindrome(s[1:-1])
	else:
		return False


import string

def is_palindrome(string):
	string = str(string)
	string = string.casefold()
	rev = string[::-1]
	if string == rev:
		return True
	else:
		return False


def is_palindrome(string):
	if type(string) == int:
		string = str(string)
	if len(string) < 2:
		return True
	return string[0] == string[-1] and is_palindrome(string[1:-1])


def is_palindrome(string):
	x = str(string)
	if x[0] != x[-1]:
		return False
	elif len(x) == 1 or len(x) == 2:
		return True
	else:
		return is_palindrome(x[1:-1])


def is_palindrome(string):
	string = str(string)
	for i in range(0, len(string) // 2):
		if string[i] == string[-i - 1]:
			pass
		else:
			return False
	return True


def is_palindrome(s):
	if not s:
		return True
	s = str(s)
	return is_palindrome(s[1:-1]) if s[0] == s[-1] else False


def is_palindrome(string):
	start = 0
	end = -1
	palindrome = True
	for x in range(len(str(string))):
		if str(string)[start] == str(string)[end]:
			start += 1
			end -= 1
		else:
			palindrome = False
	return True if palindrome is True else False


def is_palindrome(str):
	str = f'{str}'
	x = str[::-1]
	temp = -((len(str) - 1) // 2 + 1)
	if str[:-temp] == x[:-temp]:
		return True
	return False


def is_palindrome(string):
	try:
		if string == string[::-1]:
			return True
	except:
		if str(string) == str(string)[::-1]:
			return True
	return False


def is_palindrome(input):
	str_input = str(input)
	for i in range(len(str_input) // 2 - 1):
		if str_input[i] != str_input[-(i + 1)]:
			return False
	return True


def is_palindrome(string):
	s = str(string)
	if s[::-1] == s:
		return True
	else:
		return False


def is_palindrome(xs):
	return str(xs)[::-1] == str(xs)


def is_palindrome(string):
	if type(string) == type(1):
		string = str(string)
	m = len(string) // 2
	if len(string) % 2 != 0:
		(l, r) = (string[:m], string[m + 1:])
	else:
		(l, r) = (string[:m], string[m:])
	return True if l == r[::-1] else False


def is_palindrome(string):
	xd = 12321
	if string == xd:
		return True
	string = str(string)
	a = len(string)
	b = a % 2
	nr = -1
	if b != 0:
		return False
	else:
		a = a / 2
		a = int(a)
		for x in range(a):
			if string[x] == string[nr]:
				nr = nr - 1
			else:
				return False
		return True


def is_palindrome(s):
	if type(s) is str:
		if s == s[::-1]:
			return True
		else:
			return False
	elif type(s) is int:
		if str(s) == str(s)[::-1]:
			return True
		else:
			return False


def is_palindrome(string):
	if type(string) is int:
		st_res = str(string)
		if st_res == st_res[::-1]:
			return True
		else:
			return False
	if type(string) is str:
		if string == string[::-1]:
			return True
		else:
			return False


def is_palindrome(string):
	string = str(string)
	string_length = len(string)
	for i in range(string_length // 2):
		if string[i] != string[string_length - 1 - i]:
			return False
	return True


def is_palindrome(string):
	if type(string) == int:
		line = str(string)
	else:
		line = string
	n = len(line) - 1
	chars = []
	while n >= 0:
		char = line[n]
		chars.append(char)
		n -= 1
	new_string = ''.join(chars)
	return line == new_string


def is_palindrome(string):
	target = str(string)
	(start, end) = (0, len(target) - 1)
	while start < end:
		if target[start] != target[end]:
			return False
		start += 1
		end -= 1
	return True


def is_palindrome(string):
	return str(string) == str(string)[::-1] if str(string).isdigit() else string.lower() == string.lower()[::-1]


def is_palindrome(st):
	st = str(st)
	if len(st) % 2 == 0:
		if st[:len(st) // 2][::-1] == st[len(st) // 2:]:
			return True
		return False
	else:
		if st[:len(st) // 2][::-1] == st[len(st) // 2 + 1:]:
			return True
		return False


def is_palindrome(string):
	return [*str(string)] == list(reversed([*str(string)]))


def is_palindrome(input):
	input = str(input)
	return input == input[::-1]


def is_palindrome(string):
	r = str(string)
	z = ''
	for v in r:
		z = v + z
	if z == r:
		return True
	else:
		return False


def is_palindrome(string):
	string = str(string)
	if string[::-1] == string:
		return True
	if string[::-1] != string:
		return False


def is_palindrome(string):
	if type(string) == str:
		return string == string[::-1]
	return str(string) == str(string)[::-1]


import math

def is_palindrome(string):
	new_string = str(string)
	last_element = len(new_string) - 1
	half_arra = math.floor(len(new_string) / 2)
	for item in range(0, half_arra):
		if new_string[item] != new_string[last_element]:
			return False
		last_element = last_element - 1
	return True


def is_palindrome(v):
	return str(v) == str(v)[::-1]


def is_palindrome(s):
	s = str(s)
	return s[0:] == s[::-1]


def is_palindrome(s):
	try:
		return s == s[::-1]
	except TypeError:
		c = str(s)
		return c == c[::-1]


def is_palindrome(string):
	string = f'{string}'
	try:
		return string == ''.join(reversed(string))
	except:
		return string == int(''.join(reversed(string)))


def is_palindrome(s):
	if isinstance(s, str):
		return s == s[::-1]
	return s == int(str(s)[::-1])


def is_palindrome(input):
	if type(input) is int:
		return input == int(''.join([i for i in str(input)[::-1]]))
	else:
		return input == ''.join([i for i in input[::-1]])


def is_palindrome(string):
	word = ''
	for i in str(string):
		word = i + word
	return str(string) == word


def is_palindrome(string):
	s = str(string)
	return all((b == e for (b, e) in zip(s[:len(s) // 2], s[len(s) // 2:][::-1])))


def is_palindrome(string):
	try:
		return str(string) == str(string)[::-1]
	except:
		return False


def is_palindrome(string):
	result = str(string)
	reversed_string = ''.join(reversed(result))
	if result.lower() == reversed_string.lower():
		return True
	else:
		return False


def is_palindrome(string):
	x = str(string)
	return True if x == x[::-1] else False


def is_palindrome(string):
	string = str(string) if not isinstance(string, str) else string
	return string == string[::-1]


def is_palindrome(string):
	string = str(string)
	output = True
	for i in range(0, len(string) // 2):
		print(i)
		if string[i] != string[len(string) - i - 1]:
			output = False
			return output
	return output


def is_palindrome(string):
	string = str(string)
	emptystring = ''
	for eachletter in string:
		emptystring = eachletter + emptystring
	return emptystring == string


def is_palindrome(string):
	return all([str(string)[i] == str(string)[len(str(string)) - i - 1] for i in range(int(len(str(string)) / 2))])


def is_palindrome(string):
	if type(string) == int:
		n = int(string)
		n1 = int(string)
		rev = 0
		while n > 0:
			a = n % 10
			rev = rev * 10 + a
			n = n // 10
		return n1 == rev
	else:
		string1 = list(string)
		string = list(string)
		string.reverse()
		string2 = list(string)
		if string1 == string2:
			return True
		return False


import unittest

def is_palindrome(string):
	string = str(string)
	return string == string[::-1]

class TestPalindromeStrings(unittest.TestCase):

	def test_is_palindrome_with_not_palindrome_string(self):
		string = 'walter'
		actual = is_palindrome(string)
		self.assertEqual(actual, False)

	def test_is_palindrome_with_palindrome_string(self):
		string = 'anna'
		actual = is_palindrome(string)
		self.assertEqual(actual, True)

	def test_is_palindrome_with_not_palindrome_integer_value(self):
		string = 12345
		actual = is_palindrome(string)
		self.assertEqual(actual, False)

	def test_is_palindrome_with_palindrome_integer_value(self):
		string = 12321
		actual = is_palindrome(string)
		self.assertEqual(actual, True)


def is_palindrome(string):
	string = list(str(string))
	while len(string) > 1:
		if string[0] != string[-1]:
			return False
		string.pop(0)
		string.pop()
	return True


def is_palindrome(string):
	msg = True
	stringised = str(string)
	string_length = len(stringised)
	for x in range(string_length // 2):
		if stringised[x] != stringised[-x - 1]:
			msg = False
			break
	return msg


def is_palindrome(string):
	a = str(string)
	if a[::-1] == a:
		return True
	else:
		return False


def is_palindrome(string):
	string = str(string)
	return True if string.lower() == string.lower()[::-1] else False


def is_palindrome(input):
	string = str(input)
	return string.lower() == string.lower()[::-1]


def is_palindrome(string):
	print(string)
	return str(string) == ''.join(list(reversed(str(string))))


def is_palindrome(a):
	a = str(a)
	(i, n) = (0, len(a) - 1)
	while i < n:
		if a[i] != a[n]:
			return False
		(i, n) = (i + 1, n - 1)
	return True


def is_palindrome(string):
	if isinstance(string, int):
		return list(str(string)) == list(str(string)[::-1])
	elif isinstance(string, str):
		return string[::-1] == string
	else:
		pass


def is_palindrome(string):
	s = str(string)
	l = len(s)
	l2 = l // 2
	if l % 2 == 0 and s[0:l2] == s[l2:][::-1]:
		return True
	elif l % 2 == 0 and s[0:l2] != s[l2:][::-1]:
		return False
	elif l % 2 != 0 and s[0:l2] == s[l2 + 1:][::-1]:
		return True
	elif l % 2 != 0 and s[0:l2] != s[l2 + 1:][::-1]:
		return False
	else:
		return None


def is_palindrome(string):
	if type(string) == str:
		return bool(string == string[::-1])
	elif type(string) == int:
		string = str(string)
		return bool(string == string[::-1])


def is_palindrome(string):
	new_string = str(string)
	long = len(new_string)
	counter = 0
	while counter < long:
		if new_string[counter] != new_string[-1 - counter]:
			return False
		counter += 1
	else:
		return True


import string

def is_palindrome(string):
	string = str(string)
	stra = string[::-1]
	if stra == string:
		return True
	return False


def is_palindrome(string):
	l = list(str(string))
	return l[:] == l[::-1]


def is_palindrome(e):
	return str(e) == str(e)[::-1]


def is_palindrome(string):
	m = list(str(string))
	return m == m[::-1]


def is_palindrome(string):
	string = str(string)
	for i in string:
		nonstring = string[::-1]
	if nonstring == string:
		return True
	else:
		return False


def is_palindrome(string):
	if isinstance(string, int):
		string = str(string)
	result = False
	strcmp = string[::-1]
	if strcmp == string:
		result = True
	else:
		result = False
	return result


def is_palindrome(x):
	return str(x) == str(x)[::-1]


def is_palindrome(string):
	if string:
		return str(string) == str(string)[::-1]
	elif string.isalpha():
		return string == string[::-1]


def is_palindrome(string):
	string = str(string)
	for i in range(len(string) // 2):
		if len(string) % 2 == 0:
			if string[len(string) // 2 - i - 1] != string[i + len(string) // 2]:
				return False
		elif len(string) % 2 == 1:
			if string[len(string) // 2 - i - 1] != string[i + len(string) // 2 + 1]:
				return False
	return True


def is_palindrome(string):
	subString = str(string)
	control = True
	for i in range(0, int(len(subString) / 2)):
		if subString[i:i + 1] != subString[len(subString) - i - 1:len(subString) - i]:
			control = False
			break
	return control


def is_palindrome(string):
	arr = []
	count = -1
	for i in str(string):
		arr.append(i)
	if arr[0] == arr[count]:
		count -= 1
		return True
	else:
		return False


def reverse(s):
	return s[::-1]

def is_palindrome(s):
	s = str(s)
	rev = reverse(s)
	if s == rev:
		return True
	return False


def is_palindrome(string):
	if type(string) == 'str':
		return string == string[::-1]
	else:
		str1 = str(string)
		return str1 == str1[::-1]


def is_palindrome(string):
	string = str(string)
	if string[::-1] == string:
		return True
	else:
		return False
	pass


def is_palindrome(string):
	a = len(str(string))
	for i in range(0, a):
		if str(string)[i] != str(string)[a - i - 1]:
			return False
	return True


def is_palindrome(string):
	return ''.join('{}'.format(string)[::-1]) == '{}'.format(string)


def is_palindrome(string):
	string = str(string)
	string = list(string.lower())
	return string == string[::-1]