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