Check a variable in an if statement

Asked by Patrick Farrell

variable=input("yay type something")
if variable="string":
 popup ("it worked")
else:
 popup ("it didn't work")

im just wondering what im doing wrong here, it spits out an error whenever i try to have it check for variable=string am I doing something wrong here?

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
Parva Thakkar
Solved:
Last query:
Last reply:
Revision history for this message
Best Parva Thakkar (parva-email) said :
#1

Try this -

variable=input("yay type something")
if variable == "string":
 popup ("it worked")
else:
 popup ("it didn't work")

I added two equal sign in If condition

Revision history for this message
Patrick Farrell (swkuli) said :
#2

Thanks Parva Thakkar, that solved my question.