Hello I'm a newbie at python. In my function, I keep getting warnings of unused variables r,g,b,a. Can someone explain it for me?
def encode_image(self,img, msg):
length = len(msg)
if length > 255:
print("text too long! (don't exeed 255 characters)")
return False
encoded = img.copy()
width, height = img.size
index = 0
for row in range(height):
for col in range(width):
if img.mode != 'RGB':
r, g, b ,a = img.getpixel((col, row))
elif img.mode == 'RGB':
r, g, b = img.getpixel((col, row))
# first value is length of msg
if row == 0 and col == 0 and index < length:
asc = length
elif index <= length:
c = msg[index -1]
asc = ord(c)
else:
asc = b
encoded.putpixel((col, row), (r, g , asc))
index += 1
return encoded
Unused variable 'a' pylint(unused-variable)
Unused variable 'r' pylint(unused-variable)
Unused variable 'g' pylint(unused-variable)
Unused variable 'b' pylint(unused-variable)
r, g, b ,a = img.getpixel((col, row))
TypeError: cannot unpack non-iterable int object