Raw_input() not defined for RGB/HEX project (python)


Hello all,

I’ve been working on the RGB/HEX project but when I run it, I’m being told that my raw_input() function under my convert() function is not defined. Is this an issue on my end or the compiler? I’m sure I have the proper sytnax.

Also, please let me know if I have to try reposting my code.

Thank You


One workaround would be to comment out the prompts and supply values.

See if the lesson will pass with arguments instead of input.

def rgb_hex(red, green, blue):
    valid = range(256)
    if not (red in valid and green in valid and blue in valid):
        return "Input Error!"
    return "#%s" % hex((red << 16) + (green << 8) + blue)[2:].upper()

print (rgb_hex(128, 255, 0))     # #80FF00

print (rgb_hex(128, 255, 256))   # Input Error!


It’s strange because as I run the code again through the codecademy compiler, it works.

Originally, when I ran the code I was getting indent problems. To fix this I put the code through geany and after I corrected the indents, the problem I posted occurred. However, after I re-pasted my code from geany to codecademy, the code works.


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