0

I have an "if" statement and yet it only recognizes what it equals as a variable. Don't really know how to explain it very well but here's an example

a = input("Hello! What is your name?")                                                        
if a == Gabe_Newell :                                                                         
    print ("Hello, Gaben!")                                                                  
1
  • Can you explain better? I do not understand. Commented Mar 26, 2014 at 0:15

1 Answer 1

4

You have to compare with a string:

a = input("Hello! What is your name?")
if a == "Gabe_Newell":
    print ("Hello, Gaben!")

this code works for python3, if using python2, write:

a = raw_input("Hello! What is your name?")
if a == "Gabe_Newell":
    print ("Hello, Gaben!")

I assume that you want to say Hello, Gaben when user input Gabe_Nawell

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.