Return True if num is within 2 of a multiple of 10
You could simplify your code to make it faster and also avoid the 'if-else' construct:

def near_ten(num):
    a = num % 10
    return 8 &lt;= a or 2 &gt;= a


Here's another version: (Thanks to the comment of @mkrieger1)

def near_ten(num): 
    return not(2 &lt; (num % 10) &lt; 8)


I think the name of the function is misleading. Maybe you should rename it to something like: near_multiple_of_ten(num)