Type Error: 'int' object not iterable


#1

If someone can help me understand why this code is not working. It accepts my inputs for RGB values but in converting them to hexadecimal I get the following error:
image

 val = sum((red << 16) + (green << 8) + blue)
  print "%s" % (hex(val)[2:]).upper()

I know the error codes are not always accurate to the problem, so I’m not 100% certain there is an issue with this line before the print statement, but there you have it. Any help is greatly appreciated.


#2

sum() is a built-in function to add all values in an iterable together, like a list. Here you just add values together, no need for sum()


#3

That did it! By the looks of it, I was doing one, then switched to another, and then forgot to complete the change by removing the other method. I’m not sure now which way I was trying to go.

Thank you!


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.