Program to Check Integer and Float || 2D Array || Python

In this we are going to see a basic program to check if a number is Integer or Float in a 2D array in Python Programming Language.


float_count = 0
int_count = 0
list = [[3,4.0,2,8.4,6],[0,2,0.2,4,6],[9,3.5,0.32,5,4]]
for l in list:
    for item in l:
        if isinstance(item, int):
            int_count += 1
        elif isinstance(item, float):
            float_count += 1

print("Float count: {} \nInteger count: {}".format(float_count, int_count))


#ENJOY CODING


Post a Comment

FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP

Previous Post Next Post