It says the syntax is
assert condition[, _expression_]
I was hoping to put some sort of explanation of failure in an assert statement. But how to do it?
In my code I have
assert(len(list(set(colors_used_this_cycle))) == len(colors_used_this_cycle), "A color has been used twice!")
But it doesn't work. Cases where a color has been used more than once go right through it, whereas
colors_used_this_cycle.append(color)
assert(len(list(set(colors_used_this_cycle))) == len(colors_used_this_cycle)
works perfectly.
So I'd like to know what that '_expression_' in the syntax can be, and how to use it.
Thanks,
Dick Moores
_______________________________________________ Tutor maillist - [email protected] http://mail.python.org/mailman/listinfo/tutor
