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

4x4 Matrix in Python -

python - PyInstaller UAC not working in onefile mode -

javascript - Building and updating array objects -