Is_int, why typeCount =type(x)?



I don’t understand why is in solution typeCount =type(x)

Please explain. Thanks!


Which solution? Regardless, checking the type is probably not helpful since floats can hold integer values


def is_int(x):
absoluteCount = abs(x)
typeCount =type(x)
roundCount = round(absoluteCount)
if typeCount and absoluteCount - roundCount == 0:
return True
return False

it’s a codeacademy solution


That’s quite possibly the worst solution I’ve ever seen to this problem, not even considering that it’s meant to serve as an example


:slight_smile: well, it works
at least


It should read:

def is_int(x):
    return round(x) == x

Everything else in there is… ??????

abs and type are completely irrelevant, and there’s no counting being done, so the variable names are something special indeed


That’s right.

it was a bit confusing, but it’s clear now

Thanks a lot


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.