Python Forum
Conversion from hexa to decimal in loop bugging
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Conversion from hexa to decimal in loop bugging
#2
Well, "ne" is not a hexadecimal number.
Error:
decim = int(d1, 16) ValueError: invalid literal for int() with base 16: 'ne'
I can duplicate the error:
import re

def allcolors():
    colors = ("neAABB",)
    for c in colors:
        background = c
        split_strings = re.findall('..' ,background)
        print(split_strings)
        d1 = split_strings[0] # get the first item of the list, to convert it to decimal
        print(d1)

        decim = int(d1, 16)
        print('Value in hexadecimal:', d1)
        print('Value in decimal:', decim)

allcolors()
Error:
decim = int(d1, 16) ValueError: invalid literal for int() with base 16: 'ne'
Now you just need to figure where 'ne' is coming from. My guess is there is something in BLColor that is not a color. The code stopped working you started processing all the colors instead of just the last one.
Reply


Messages In This Thread
RE: Conversion from hexa to decimal in loop bugging - by deanhystad - Feb-22-2022, 04:32 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Write the XML file from elementtree with hexa decimal encoding Dillibabu 4 3,517 Dec-24-2019, 10:10 AM
Last Post: Dillibabu
  Change of mass hexa data kosteloos 0 1,790 Aug-12-2019, 10:04 AM
Last Post: kosteloos
  testing for Decimal w/o importing decimal every time Skaperen 7 4,514 May-06-2019, 10:23 PM
Last Post: Skaperen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020