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
list
s. Therange()
function returns arange
object. These iterators behave likelist
s in many ways, but not all, and one difference is that you cannot use+
to concatenate them. Solution: first convert to alist
like so:Cheers,
Sebastiaan
There's much bigger issues in the world, I know. But I first have to take care of the world I know.
cogsci.nl/smathot