more complicated counterbalancing - creating own list
in OpenSesame
This is my script:
BalanceList1 = range(1,7) + range(13,19)
BalanceList2 = range(7,13) + range(19,25)
if self.get('subject_nr') in BalanceList1:
# do something
if self.get('subject_nr') in BalanceList2:
# do something
This is my error message
TypeError: unsupported operand type(s) for +: 'range' and 'range'
Comments
Hi,
In Python 3—which you're apparently using, and good for you, because it's an improvement over Python 2—many functions return special iterator objects, instead of
lists. Therange()function returns arangeobject. These iterators behave likelists in many ways, but not all, and one difference is that you cannot use+to concatenate them. Solution: first convert to alistlike so:Cheers,
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!