Given a number, write a function to output its reverse digits.  (e.g. given 123 the answer is 321)


Numbers should preserve their sign; i.e. a negative number should still be negative when reversed.

### Examples
```
 123 ->  321
-456 -> -654
1000 ->    1
```

Source: codewars | Difficulty: EASY
Tags: Fundamentals

Starter code: def reverse_number(n):
	

Solutions:
def reverse_number(n):
	s = str(n)
	ret = int('-{}'.format(s[:0:-1]) if '-' in s else s[::-1])
	return ret


def reverse_number(n):
	rev = 0
	temp = n
	dig = 0
	if n < 0:
		n = abs(n)
	while n > 0:
		dig = n % 10
		rev = rev * 10 + dig
		n = n // 10
	if temp < 0:
		return -rev
	else:
		return rev


def reverse_number(n):
	if str(n)[0] == '-':
		return -int(str(n)[:0:-1])
	else:
		return int(str(n)[::-1])


def reverse_number(n):
	return int(str(abs(n))[::-1]) * (-1) ** (n < 0)


def reverse_number(n):
	return min(1, max(-1, n)) * int(str(abs(n))[::-1])


reverse_number = lambda n: int(str(abs(n))[::-1]) * (1 - 2 * (n < 0))


def reverse_number(n):
	r = str(n).replace('-', '')[::-1]
	return int(r) if n > 0 else -int(r)


def reverse_number(number):
	if number >= 0:
		return int(str(number)[::-1])
	else:
		return -int(str(number)[:0:-1])


def reverse_number(n):
	result = 0
	is_neg = False
	if n < 0:
		n = -n
		is_neg = True
	while n != 0:
		result *= 10
		result += n % 10
		n = int(n / 10)
	if is_neg:
		return -result
	else:
		return result


def reverse_number(n):
	n_rev = int(''.join(reversed([c for c in str(n) if c.isdigit()])))
	return n_rev if n >= 0 else -n_rev


def reverse_number(n):
	spacer = n < 0
	return int(['', '-'][spacer] + str(n)[spacer:][::-1])


def reverse_number(n):
	if n < 0:
		return int(n.__str__()[1:][::-1]) * -1
	else:
		return int(n.__str__()[::-1])


def reverse_number(n):
	return int('-' * (n < 0) + ''.join(reversed(str(abs(n)))))


def reverse_number(n):
	n = str(n)
	n = list(n)
	n.reverse()
	if n.count('-') > 0:
		n.pop()
		n.insert(0, '-')
	a = str()
	for i in n:
		a += str(i)
	return int(a)


def reverse_number(n):
	n = str(n)
	l = len(n)
	if n[0] == '-':
		n = int(n[:l * -1:-1]) * -1
	else:
		n = n[::-1]
	return int(n)


def reverse_number(n):
	si = len(str(n))
	i = si
	s = ''
	if n >= 0:
		while i > 0:
			s += str(n % 10)
			n = n // 10
			i -= 1
		return int(s)
	else:
		n = -1 * n
		while i > 1:
			s += str(n % 10)
			n = n // 10
			i -= 1
		return -1 * int(s)


from numpy import sign

def reverse_number(n):
	return sign(n) * int(str(abs(n))[::-1])


reverse_number = lambda n: (-1 if n < 0 else 1) * int(str(abs(n))[::-1])


def reverse_number(n):
	if n > 0:
		f = int(str(abs(n))[::-1])
	else:
		f = -int(str(abs(n))[::-1])
	return f


def reverse_number(n):
	if n < 0:
		s = str(n)[1:]
		return int(s[::-1]) * -1
	return int(str(n)[::-1])


def reverse_number(n):
	sN = str(n)
	x = sN[::-1]
	new = ''
	for i in x:
		if i == '-':
			continue
		else:
			new += i
	if n < 0:
		return -int(new)
	else:
		return int(new)


def reverse_number(n):
	str_num = str(abs(n))[::-1]
	return -1 * int(str_num) if n < 0 else int(str_num)


def reverse_number(n):
	ans = 0
	if n >= 0:
		while n > 0:
			ans *= 10
			ans += n % 10
			n = n // 10
		print(ans)
		return ans
	elif n < 0:
		n = n * -1
		while n > 0:
			ans *= 10
			ans += n % 10
			n = n // 10
		print(ans)
		return ans * -1


def reverse_number(n):
	aux = n
	reverso = 0
	while abs(n) > 0:
		ultimoDigito = abs(n) % 10
		n = abs(n) // 10
		reverso = reverso * 10 + ultimoDigito
	if aux > 0:
		return reverso
	else:
		return reverso * -1


def reverse_number(n):
	number = str(n)
	list = []
	index = 0
	if n < 0:
		for i in number:
			if i.isdigit() == True:
				list.insert(0, i)
			new_num = ''.join(list)
		return 0 - int(new_num)
	else:
		for i in number:
			if i.isdigit() == True:
				list.insert(0, i)
		for i in list:
			while i == 0:
				index += 1
			else:
				break
		new_num = ''.join(list[index:])
		return int(new_num)


def reverse_number(n):
	return int(str(n)[::-1] if '-' not in str(n) else '-' + str(n).replace('-', '')[::-1])


def reverse_number(n):
	if n >= 0:
		d = [int(i) for i in str(n)]
		r = d[::-1]
		w = int(''.join(map(str, r)))
		return w
	if n < 0:
		m = abs(n)
		d = [int(j) for j in str(m)]
		r = d[::-1]
		w = int(''.join(map(str, r)))
		return w * -1


def reverse_number(n):
	x = int(str(abs(n))[::-1])
	return x if n > 0 else -x


def reverse_number(n):
	a = str(n)[::-1]
	b = ''
	if '-' in a:
		b = '-' + a[:-1]
		return int(b)
	else:
		return int(a)


def reverse_number(n):
	if str(n)[0] == '-':
		return int('-{}'.format(str(n)[1:][::-1]))
	elif n == 0:
		return 0
	else:
		return int(str(n)[::-1].lstrip('0'))


def reverse_number(number):
	splitted = [x for x in str(number)]
	if '-' in splitted:
		splitted.remove('-')
		splitted.reverse()
		splitted.insert(0, '-')
		return int(''.join(splitted))
	else:
		splitted.reverse()
		return int(''.join(splitted))


def reverse_number(n):
	if n < 0:
		return int(''.join([x for x in str(n)[1:][::-1]])) * -1
	else:
		return int(''.join([x for x in str(n)[::-1]]))


def reverse_number(n):
	num = abs(n)
	if n < 0:
		return int(str(num)[::-1]) * -1
	else:
		return int(str(num)[::-1])


def reverse_number(n):
	if abs(n) != n:
		num = str(n)[::-1]
		return int('-' + num[:-1])
	return int(str(n)[::-1])


def reverse_number(n):
	sign = -1 if n < 0 else 1
	return sign * int(str(n).replace('-', '')[::-1])


def reverse_number(n):
	s = str(abs(n))
	result = int(s[::-1])
	return result if n >= 0 else -1 * result


def reverse_number(n):
	number = str(n)
	if n >= 0:
		number = number[::-1]
		return int(number)
	number = number[-1:0:-1]
	return int(number) * -1


def reverse_number(n):
	return int(str(abs(n))[::-1]) * (n < 0 and -1 or 1)


def reverse_number(n):
	if n < 0:
		return -int(str(n)[1:][::-1])
	try:
		return int(str(n).rstrip('0')[::-1])
	except:
		return 0


def reverse_number(n):
	if n == 0:
		return 0
	elif n < 0:
		ok = True
		n = -n
	else:
		ok = False
	while n % 10 == 0:
		n = n / 10
	aux = str(int(n))[::-1]
	if ok:
		return -int(aux)
	return int(aux)


def reverse_number(n):
	if n < 0:
		n = str(n)
		s = n[1:len(n)]
		new_n = n[0] + s[::-1]
		return int(new_n)
	else:
		n = str(n)
		n = n[::-1]
		return int(n)


def reverse_number(n):
	res = []
	s = str(n)
	if s[0] == '-':
		res = '-' + s[:0:-1]
	else:
		res = s[::-1]
	return int(res)


def reverse_number(n):
	x = str(n)
	if '-' in x:
		y = list(x)
		y.reverse()
		y.remove('-')
		return int(''.join(y)) * -1
	else:
		y = list(x)
		y.reverse()
		return int(''.join(y))


def reverse_number(n):
	if str(n)[0] == '-':
		new = int('-' + ''.join([str(n)[1:][-1 - i] for i in range(len(str(n)) - 1)]))
	else:
		new = int(''.join([str(n)[-1 - i] for i in range(len(str(n)))]))
	if new == 0:
		return new
	else:
		return int(str(new).lstrip('0'))


def reverse_number(n):
	neg = 0
	if abs(n) != n:
		n = -n
		neg = 1
	n = int(str(n)[::-1])
	return -n if neg == 1 else n


def reverse_number(n):
	try:
		return int(str(n)[::-1])
	except:
		return -int(str(n)[::-1][:-1])


def reverse_number(n):
	return int(str(abs(n))[::-1]) if n > -1 else -int(str(abs(n))[::-1])


def reverse_number(n):
	return int(str(n)[::-1].replace('-', '')) * n / abs(n) if n != 0 else 0


def reverse_number(n):
	digits = 0
	num = 0
	if n >= 0:
		num = n
		sign_n = 1
	else:
		num = -n
		sign_n = -1
	while num >= 1:
		num /= 10
		digits += 1
	n = n * sign_n
	l_direct = list()
	for i in range(0, digits):
		l_direct.append(str(n % 10))
		n = int(n / 10)
		i += 1
	s = ''
	for j in range(0, digits):
		s = s + l_direct[j]
	if s == '':
		result = 0
	else:
		result = int(s) * sign_n
	return result


def reverse_number(num):
	ans = int(str(num)[::-1]) if num >= 0 else -int(str(-num)[::-1])
	return ans


def reverse_number(n):
	number = n
	is_negative = False
	if n < 0:
		is_negative = True
	number = str(number)
	number = number.strip('-')
	number = number[::-1]
	number = number.strip('0')
	if number == '':
		number = '0'
	if is_negative:
		number = '-' + number
	return int(number)


import unittest

def reverse_number(n):
	revered_num = int(str(abs(n))[::-1])
	if n < 0:
		return int('-{}'.format(revered_num))
	return revered_num

class TestReverseNumber(unittest.TestCase):

	def test_reverse_number_with_n_is_one_digit(self):
		n = 5
		actual = reverse_number(n)
		self.assertEqual(actual, 5)

	def test_reverse_number_with_negative_sign(self):
		n = -123
		actual = reverse_number(n)
		self.assertEqual(actual, -321)

	def test_reverse_number_without_any_sign(self):
		n = 123
		actual = reverse_number(n)
		self.assertEqual(actual, 321)

	def test_reverse_number_should_return_1_when_given_n_is_1000(self):
		n = 1000
		actual = reverse_number(n)
		self.assertEqual(actual, 1)


def split(word):
	return [char for char in word]

def reverse_number(n):
	isNegative = False
	if n < 0:
		isNegative = True
	output = ''
	stringLst = split(str(n))
	stringLst.reverse()
	for i in stringLst:
		output += i
	if isNegative:
		output = output.replace('-', '')
		result = int(output)
		return result * -1
	else:
		return int(output)


def reverse_number(n):
	res = int(str(abs(n))[::-1])
	return res if n >= 0 else -res


def reverse_number(n):
	try:
		return int(str(abs(n))[::-1]) * (n // abs(n))
	except ZeroDivisionError:
		return 0


def reverse_number(n):
	result = ''
	if n == 0:
		return 0
	elif n > 0:
		result = str(n)[::-1]
		return int(result)
	else:
		result = str(n)[1:][::-1]
		return int(result) * -1


def reverse_number(n):
	if str(n)[0] == '-':
		return -1 * int(str(n).split('-')[1][::-1])
	return int(str(n)[::-1])


def reverse_number(n):
	return int(''.join(reversed(str(abs(n))))) * (-1 if n < 0 else 1)


def reverse_number(n):
	if n < 0:
		a = str(n)[1:]
		return int('{}{}'.format(str(n)[0], a[::-1]))
	else:
		return int(str(n)[::-1])


def reverse_number(n):
	s = ''
	if n < 0:
		s = '-'
	return int(s + ''.join((i for i in reversed(str(abs(n))))))


def reverse_number(n):
	lst = [x for x in list(str(n))]
	lst.reverse()
	if n > -1:
		result = int(''.join(lst))
	else:
		result = int(''.join(lst[:-1])) * -1
	return result


def reverse_number(n):
	result = int(''.join(reversed(list(str(abs(n))))))
	if n > 0:
		return result
	else:
		return -result