class Solution(object):
def reverse(self, x):
"""
:type x: int
:rtype: int
"""
if x>=0:
f=1
else:
f=-1
x=x*f
l=[]
while(x/10>=1):
l.append(x%10)
x=x/10
l.append(x)
s=""
for i in l:
s+=str(i)
s=int(s)*f
if s>(2**31)-1 or s<-(2**31):
return 0
return s