Why does using 'is' instead of equals ( == ) for comparison of integers return different results in python? -
this question has answer here:
- how test 1 variable against multiple values? 16 answers
def makes10(a, b): return ((a or b) 10) or (a+b 10) makes10(9, 10) false
i hope above same below, returning different results.
def makes10(a, b): return (a == 10 or b == 10 or a+b == 10) makes10(9, 10) true
>>> (1 or 10) 10 false >>> (10 or 1) 10 true >>> (1 or 10) 1
using or , check if either of numbers 10 doesn't work...
the bottom version of makes10() way go. @wooble said, don't use compare integer values.
Comments
Post a Comment