IPV4 to IPV6 converter

IPV4 address

IPV6 address

try:

    ip=list(x for x in input("Enter IPV4 Address ").split("."))

    s="0:"*6

    dec=0

    count=0

    

    if len(ip)==4:

         for i in ip:

             n=int(i) 

             if n not in range(0,256):

                  raise Exception("Ip Address can be in the range 0-255 ")

             else:

                 


                 b=format(n,'02x')

                 if n<16:

                     b=b[::-1]

                 s+=b

                 count+=1


                 if count==2:

                     s+=":"



                

         print("IPV4 address is "+".".join(ip))

         print("IPV6 address is "+s)



    else:

         raise Exception("Ip Address must have 4 parts separated by '.' ")


except Exception as e:

    print(e)