Python if Statement not working


#1

I am a beginner in Python and I need help. My if Statement is not working and I don't get it

print (input("Wanna Here a Joke?"))
a = input()
b = "No"

if a == b:
print("ok")

else: print("My Jokes Get it?")


#2

You are having indentation problems. In python, indentation is very important to tell the computer what code goes where. Your code inside your if/else needs to be indented for it to work. Also you have to use raw_input.
Corrected code:

a = raw_input("Wanna hear a joke?")
b = "No"

if a == b:
    print("ok")

else: 
    print("My Jokes Get it?")

Note the indentation and input syntax


#3

I am using Python 3. something and I copied and pasted what you did but the raw_input is said to have a error sooo...... are you talking about python 2?


#4

Nevermind I deleted variable b and put "No" instead


#5

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