I'm trying to get the message "INVALID VALUE" when the user doesn't enter the correct characters, but the program is restarted without printing the message. Can you help me?
# Print "Male" when the user types "M" and "Female" when the user types "F"
def m_ou_f():
    mens_erro = "INVALID VALUE"
    while True:
        try:
            sex = str(input("Type M for Male or F for Female: "))
            sex == "M" or sex == "F" or sex == "f" or sex == "m"
        except:
            print(mens_erro)
            continue
        else:
            return sex
            break
while True:
    sex = m_ou_f()
    try:
        sex == "M" or sex == "F" or sex == "f" or sex == "m"
    except:
        print("INVALID VALUE!")
        continue
    else:
        if sex == 'M' or sex == 'm':
            print("Male")
            break
        elif sex == 'F' or sex == 'f':
            print("Female")
            break
 
     
    