Python 3 - A simple text string from user input to hex
<p>I want my code to accept user input then convert it to Hex</p>

<pre><code>hex_name = input("Would you like to convert to hex?,Type Yes or No: ")


if hex_name == 'Yes' or hex_name == 'yes' or hex_name == 'YES':
        hex_input = input("Enter String value here:")
        h_input = binascii.hexlify(b'hex_input')
        print(hex_input, "Converts to: ", h_input)

        #when user enters no
elif hex_name == 'No' or hex_name == 'no' or hex_name == 'NO':
    print("You said", hex_name, "have a nice day!")

    #when user enters an empty space or hits the enter-bar
elif hex_name == '' or hex_name == ' ' or hex_name == '  ':
    print("Empty value detected, please try again")

#Ends program if user enters anything than a yes or no
elif  hex_name != 'Yes' or hex_name != 'yes':
        print("Sorry", hex_name, "is not a valid input")
        print("Please enter Yes or No, ", "have a nice day!")
</code></pre>

<p>'''The code works but it prints the hex value of hex_input instead of the user input, What am i doing wrong?'''</p>

<p>I am all very new to python and i use python 3.3.2</p>

<p>Remove the quotes around <code>hex_input</code>:</p>

<pre><code>binascii.hexlify(bytes(hex_input))
</code></pre>

python python-3.3