Not Equal to Each Other?
stephen.thorne at gmail.com
Fri Nov 4 03:00:32 CET 2005
On 3 Nov 2005 17:01:08 -0800, ale.of.ginger at gmail.com
<ale.of.ginger at gmail.com> wrote:
> the above so that all the data in one row is not equal to each other,
> is there something I can write to make it simpler? For example,
> (cellboard is not cellboard is not ... cellboard) only worked
> for the numbers to the left and right of the cell - is there anyway I
> can expand this to cover all numbers in a set range?
Python has an operator call 'in', which will allow you to do what you're after.
"1 in (1,2,3)" will be true
"4 in (1,2,3)" will be false
"not 1 in (1,2,3)" will be false
So you'd be after something along the lines of:
not cellboard in (cellboard, ...., celboard).
This seems quite tedious to write, maybe you should consider something
along the lines of using slicing:
not celboard in cellboard[1:8]
I hope i have given you enough tools to do what you're trying to do.
More information about the Python-list