For this Question: A magic number is a natural number that contains both the digits 7 and 9 in it. For eg:- 79, 879, 53729 etc. 
Given a number N, your task is to find the closest Magic number from the given number N.

Note:- If more than one answer exists return the minimum one<b>User Task:</b>
Since this will be a functional problem, you don't have to take input. You just have to complete the function <b>MagicNumber()</b> that takes integer N as argument.

Constraints:-
1 <= N <= 100000Return a magic number closest to the given number N.Sample Input:-
8

Sample Output:-
79

Sample Input:-
900

Sample Output:-
897, I have written this Solution Code: def check(N):
    if(N<0):
        return 1
    a=0
    b=0
    while(N):
        if(N%10==7):
            a=1
        if(N%10==9):
            b=1
        N=N//10
    if( a==1 and b==1):
        return 0
    return 1

def MagicNumber(N):
    i=0
    while(check(N-i)==1 and check(N+i)==1):
        i=i+1
    if(check(N-i)==0):
        return N-i
    return N+i

, In this Programming Language: Python, Now tell me if this Code is compilable or not?