def reverse(intOrStr): list_str = list(str(intOrStr)) list_str.reverse() res = "".join(list_str) if type(res) == type(intOrStr): return res else: return int(res)
- def reverse(intOrStr):
reversed = ''ss = ''if str(intOrStr) == intOrStr:for i in range(len(intOrStr)):reversed += intOrStr[len(intOrStr)-i-1]return reversedelse:ss = str(intOrStr)for i in range(len(ss)):reversed += ss[len(ss)-i-1]return int(reversed)- list_str = list(str(intOrStr))
- list_str.reverse()
- res = "".join(list_str)
- if type(res) == type(intOrStr):
- return res
- else:
- return int(res)