# Help me to solve this problem

#1

``````def is_int(x):
if type(x)=="int":
return True
for index,i in enumerate(str(x)):
if i=="-": return True
elif i==".":
for x in str(x),range(index+1,len(x)):
while(x==0):
return True
break
else:
return False``````

#2

here:

``if type(x)=="int":``

why check if the data type of x equals a string? `"int"` is a string, `int` is a data type

here:

``if i=="-": return True``

`-3.4` is not a integer, so check if the first character is a `-` won't do

This is a complicated solution, are you sure you want to got this way?

you learned the modulo operator, you learned `abs()`, maybe you want to go back to the drawing board?

#3

Problem is:if we pass an values like(integers) 4,4.0,-4,-4.0 the function
returns True.. because they are true Integers

#4

how is that a problem? `4`, `4.0`, `-4` and `-4.0` are considered integers in this program, so it should return True?

#5

yes sir, and i don't konw how to use the abs(), for this problem

#6

well, that is the challenge. What does `abs()` do and how might we use that to our advantage here? Or the modulo operator? You could also use `int()`

Pick whatever you feel comfortable with. How could we use any of this function, because the code you posted original in this topic, looks really complicated, or do you think it can bring you close to the solution?

#7

please , give some ideas to solve this problem.
abs()-return the value , how far the variable from zero

#8

so if we `x` minus the absolute value of `x`, we get 0 for non decimal numbers, `.0` for decimal integers and `.1` for example for `5.1`, this could help us in determining if `x` is a integer

#9

This is my actual question:
An integer is just a number without a decimal part (for instance, -17, 0, and 42 are all integers, but 98.6 is not).

For the purpose of this lesson, we'll also say that a number with a decimal part that is all 0s is also an integer, such as 7.0.

This means that, for this lesson, you can't just test the input to see if it's of type int.

If the difference between a number and that same number rounded down is greater than zero, what does that say about that particular number?

#10

# Is the code is right??

def is_int(x):
if type(x)==int:
return True
elif (int(x)==x):
return True
else:
return False

print is_int(5.0)

#11

that looks right

well done

#12