python - If N is equal to an integer -


this question has answer here:

i'm writing function runs through list of elements, , operation on list elements integers. looks this:

for n in list1:    if n == int:          #do stuff 

what i'm struggling how write out loop detect if element integer. should this? can't find in docs of python (although maybe haven't looked deep enough in).

thanks help.

use isinstance() function:

for n in list1:    if isinstance(n, int):        # stuff 

Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -