Is_int help


the error is "Traceback (most recent call last):
File "python", line 15, in
File "python", line 10, in is_int
TypeError: unsupported operand type(s) for &: 'bool' and 'str'"

It's supposed to tell whether a number is an integer. please help! I thought this would work.

Replace this line with your code. 
its = True

def is_int(x):
    decimal = False
    for it in str(x):
        print it
        if it == ".":
            decimal = True
        elif decimal == True & it < 1:
            its = False
    return its


Given that we have determined x to be a number, it is safe to assume that it will contain only one decimal point. If we go down this road we clearly contravene the instructions, which explicitly state that 7.0 is an integer. The decimal point then, is not an indicator that we can rely upon.

Recommend take another tack.


The decimal point is just to tell if the place I'm analyzing is after the decimal point. then we have the elif that says that if the place is after the decimal place and it is not a zero return False.


We need to confirm that it is in fact a number before checking for the decimal point. That is adding to the work load.

def is_int(x):
    if not isinstance(x, (int, float)): return "Not a Number"
    # code

Now we know it is a number and can proceed with checking for the dot.

    if '.' in str(x):
        n = str(x)[-str(x).index('.')-1:]
        if int(n) != 0: return False
    return True