Python: How to convert a rgb or hex value to single color values
with all sliders to 255 it gives: [100.390625, 100.390625, 100.390625]
This is an artifact of the print command. It means that you have a list with three values in the list.
If you print the three variable in one line, you will get three values separated by spaces
>>> print r, g, b100.390625 100.390625 100.390625
Your math is forcing the values of the list to floating point. You want it as integers. When you round it down, you are placing the integer values into floating point variables which would still output with the final .0 Change
triple1pwm = [x / 255.0 * 100 for x in triple1]
to
triple1pwm = [int(x*100/255) for x in triple1]
This will round down to the integer value.
You can also use
triple1pwm = [x*100//255 for x in triple1]
This is because of the order of operations that you have
>>> 25 // 255 * 1000>>> 25 * 100 // 2559
Note that as long as x is floating point or you use 100.0 or 255.0 then you will get a floating point result so that
>>> 25.0 * 100 // 2559.0
while
>>> int(25.0 * 100 / 255)9
Now you can say
r, g, b = triple1pwm
or
r, g, b = [int(x*100/255) for x in triple1]