← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #253152]: how to select two images from different lists

 

Question #253152 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/253152

    Status: Open => Answered

Eugene S proposed the following answer:
Hi,

First of all, you have a couple of problems in your example code:
1. You can't create a list with name 'list' as that's a reserved word
2. In Python a list is defined by '[]' rather that '()'. When you use '()', you will create a tuple.

I'm not sure I understood your question completely but to choose items
from 2 lists in an orderly manner you can follow several approaches. For
example:

lst1 = [item1,item2,item3]
lst2 = [item4,item5,item6]


OPTION 1: 

for item in lst1:
   itemOne = item
   itemTwo = lst2.index(item) #This will return n item from lst2 location at the same location itemOne located in lst1


OPTION 2:

counter = 0

for item in lst1:
   itemOne = lst1[counter]
   itemTwo = lst2[counter]
   counter += 1


OPTION 3:

while (lst.__len__() > 0):
   itemOne = lst1.pop(0)
   itemTwo = lst2.pop(0)


And more...

NOTE: For all above cases, the assumption is that you have the same
number of items in both lists.


Cheers,
Eugene

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.