When I try to pick the item I want, I could not create a List.
But if it is just in range, it works fine.
Like following code, Could any method to solve this??
aa = []
bb = []
for item in self.findItems():
aa += [2]
bb = [2 for itme in self.findItems()]
self.say(aa) # say []
self.say(bb) # say []
for i in range(4):
aa += [2]
self.say(aa) # say [2, 2, 2, 2]
Perhaps self.findItems()
is returning an empty list? So you get zero iterations and your resulting list is empty.
By double Checking.
I find that if it’s in the for loop, it would be wrong as following code.
for i in range(1):
items = [item for item in self.findItems() if True]
self.say(items)
But If I put it outside the for loop, it works fine.
items = [item for item in self.findItems() if True]
self.say(items)