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

python - PyInstaller UAC not working in onefile mode -

ios - Pass NSDictionary from Javascript to Objective-c in JavascriptCore -

wso2is - WSO2 IS 5.0.0 SP1 After restart there is authentication error -