Reverse negativeNum

    0

    0

    Mahendra Kumar

    beginnerlogic

    Reversing a given negative number

    def reverseNum(n): #user-defined function
       n = str(n)
       if n[0] == '-':
          a = n[::-1]
          return f"{n[0]}{a[:-1]}"
       else:
          return n[::-1]
    # take inputs
    num = input("inter a negative number:")
    # calling function and display result
    print('The reverse number is =', reverseNum(num))
    
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Explore
    • Cookbooks
    • Playground
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.