If statement problem

Asked by p

new to sikuli. Im trying to use an if statement to select a different options in a list.
so select 1st option first then select 2nd option the 2nd time around select 1st option 3rd time round. this is what i got so far. Is there a better way to do it.

for n in range(3):
    count = 0
    if count : 0
    click("image1.png")
    count = count + 1
    click("imageOK.png")
else :
    click("image2.png")
    count = count - 1
click("imageOK.png")

Question information

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

you already have n as a counting value (takes 0, 1 and 2).

for n in range(3):
    if n == 0 or n == 2:
        click("image1.png")
        click("imageOK.png")
    else :
        click("image2.png")
        click("imageOK.png")

n == 0 or n == 2
could be replaced by
n%2 == 0 (checks wether the remainder of dividing by 2 is 0)

Can you help with this problem?

Provide an answer of your own, or ask p for more information if necessary.

To post a message you must log in.