Question
For this exercise, the not_sum_to_ten()
function will return True
for the numbers 9 and -1 and return False
for 9 and 1. If I wanted to make the function ignore whether the numbers were negative, how would that work?
Answer
The Python abs()
function will return the absolute value of a number. Calling the abs()
function during the check as shown below will cause the function to treat 9 and -1 the same as 9 and 1.
if (abs(num1) + abs(num2) != 10):