Don't understand why it's wrong


#1

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:
        a.append(i)
    
    for i in range(0, len(a)):
        if a[i] == '.':
            if a[i+1] != 0:
                return False
    else:
        return True

3. is_int HELP!
#2

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":