Don't understand why it's wrong


Hey, can u guys help me? My code is here - don't understand why it's wrong :frowning:

import math
import string

def is_int(x):
    num = str(abs(x))
    a = []
    for i in num:
    for i in range(0, len(a)):
        if a[i] == '.':
            if a[i+1] != 0:
                return False
        return True

3. is_int HELP!

the problem is in this line:

if a[i+1] != 0:

a[i+1] is a string, and you are comparing with a integer, for example:

"0" != 0

which is true, (they are not equal, different data types), you might want to compare with a string instead:

if a[i+1] != "0":