1

I have created a program in python which is a list of multiple data types and we are trying to sum only int types

a=[4,5,6,False,8,'18']

sum=0
for i in a:
    if isinstance(i,int):
        print("i=",i)
        sum+=i
        print(sum)

But even for False isinstance is showing True. kindly update why

user2779311
  • 1,688
  • 4
  • 23
  • 31

0 Answers0