if condition statement issues

Asked by Viral

Hi,

I wanted to know how take the user input(text) and pass it as a selection parameter for an if condition.

Here is my sample code:

basically the shows a popup and asks for user input. if user sends "s" key it should execute the "s" chunk of code, for anything other than "s" implement the second chunk.

e.g:

option = input("signin = s regiester = r")
if option is "s":
 chunk of code....

else:
 another chunk of code

My problem is that the script is always implementing the "else" portion regardless of my input.

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
Viral
Solved:
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

you have to write
if option == "s":

since you want to compare the CONTENTS of the two objects.

option is "s" would only be true, if the two variables would reference the same object (same id), which could never be true, since a "any text" always creates a new object.

Revision history for this message
Viral (viralnparekh) said :
#2

thanks Raiman for the quick solution.