Ad
Code
Diff
  • 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 reversed
    • else:
    • 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)