Nested loops

Asked by Sao

I have a number of pictures and instructions I want my script to go through and for every round i want it to move to the next set of instruction and picture. In this example I want it to use 1.png with x, the next round 2.png with y and so on

pictures = [[1.png],[2.png],[3.png]]

instructions = [[x],[y],[z]]

I have tried with a lot of different alternatives with nested for loops like

for p in pictures:
    for i in instructions:
        paste(i[0])
        click(p[0])

But in this case it will paste instruction x,y,z and click picture 1.png in between.

How do I get it to, after it paste x and click 1.png, paste y and click 2.png?

Thanks again for a great program and good support

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
Sao
Solved:
Last query:
Last reply:
Revision history for this message
Karl (k-d) said :
#1

Unless you have a specific reason to use the double brackets, you don't need them. If you do, you'll just have to append a [0] to the code below.

for i in range(0,len(pictures)):
    paste(instructions[i])
    click(pictures[i])

Revision history for this message
Sao (e-bm) said :
#2

It didn't let me. Got this error code

[error] TypeError ( paste(): 1st arg can't be coerced to String )

Revision history for this message
Sao (e-bm) said :
#3

Nevermind, appended the [0] to the code. Works perfectly now, ty!