Nov-30-2018, 04:51 PM
y == yi
evaluates to a boolean value (True or False). But bools are actually a subclass of int, so True = 1 and False = 0. So if y == yi, it selects X[1], and if y != yi it selects X[0].There was a ternary expression added to Python to avoid this sort of code, so that could be rewritten as:
Xi = X[1] if y == yi else X[0]
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures