How to determine wrong data type
<p>I use the following to see if the data is an integer, if not it tells me. Is there a way to determine which one is incorrect so can change it or would i have to create the same loop for every item?</p>

<pre><code>while i_input == True:
    try:
        i_pointstarget=int(pointstarget.get())
        i_ap1=int(ap1.get())
        i_ap2=int(ap2.get())
        i_ap3=int(ap3.get())
        i_ap4=int(ap4.get())
        i_ap5=int(ap5.get())
        i_ap6=int(ap6.get())
    except ValueError:
        i_input=False
        continue
    else:
        break
</code></pre>

<p>Thanks for any help :)</p>

<p>Instead of trying to convert to <code>int</code> (btw <code>int(1.23)</code> works, returning <code>1</code>) you can also use <a href="https://docs.python.org/3/library/numbers.html" rel="nofollow">numbers</a> like</p>

<pre><code>import numbers
def is_integral(n): # actually not checking for int but also other int-equivalents
    return isinstance(n,numbers.Integral)
</code></pre>

<p>if you want to check if you have a number which can loslessy be converted to an integral number (like <code>int</code>) you can do</p>

<pre><code>import numbers
def exact_integral(n): # check if n can be exactly represented as an integer
    return isinstance(n,numbers.Complex) and n==round(n.real)
</code></pre>

python