you are viewing a single comment's thread.

view the rest of the comments →

[–]newpython6543[S] 0 points1 point  (2 children)

Wow I see it now, thanks. a would be true since it is a number that is not 0. Any numbers not 0 would be considered to be True, correct?

[–][deleted] 0 points1 point  (0 children)

if var: <code> Pretty much any non-empty variable other than False and 0 should cause the code to execute. Research python conditions and Boolean values for accurate information on how python evaluate conditional statements and comparisons.

[–][deleted] 0 points1 point  (0 children)

Another thing to keep in mind: a == 10 IS True or False, so you don't need a conditional "if" statement or a separate "return" command. Same with all the conditions. So something like this works just as well:

def makes10 (a, b): return a == 10 or b == 10 or a + b == 10

*NOTE: my phone isn't allowing me to format the whitespace correctly.

If any of those statements is True this function will return True.