I need help on the RGB to Hex converter project. I'm trying to run it but it says there is something wrong with my code.

here is my code, can someone please check what is wrong with it because i can't figure it out:

def rgb_hex():

invalid_msg = "Sorry, that is invalid."

red = int(raw_input("Enter a red value."))

if red < 0 or red > 255:

print "Sorry, that is invalid."

return

green = int(raw_input("Enter a green value."))

if green < 0 or green > 255:

print "Sorry, that is invalid."

return

blue = int(raw_input("Enter a blue value."))

if blue < 0 or blue > 255:

print "Sorry, that is invalid."

return

print "%s" % hex(val)[2:].upper()

return

def hex_rgb():

hex_val = raw_input("Enter a hexadecimal value.")

if len(hex_val) != 6:

print "Sorry, that is invalid."

return

else:

hex_val = int(hex_val, 16)

return

two_hex_digits = 2 ** 8

blue = hex_val % two_hex_digits

hex_val >> 8

green = hex_val % two_hex_digits

hex_val >> 8

red = hex_val % two_hex_digits

print "Red: %s Green: %s Blue: %s" % red, green, blue

return

def convert():

while True:

option = raw_input("Enter 1 to convert RGB to HEX. Enter 2 to convert HEX to RGB. Enter X to Exit: ")

if option == "1":

print "RGB to HEX..."

rgb_hex()

elif option == "2":

print "Hex to RGB..."

hex_rgb()

elif option == "X" or option == "x":

break

else:

print "Error"

convert()

Someone please help me!