HomePagev2 Forums Python Discussions count of data types from a list


  • count of data types from a list

  • Sai Chaitanya Kumbhari Chaitanya Kumbhari

    December 21, 2020 at 4:04 pm

    hi fellas,

    for loop practice 2 i wrote a code like this

    def dtype(n):

    # yield helps to store multiple output in the function function alows 1 return statement

    #isinstance helps fine type of the element in the given list

    def count_data_type(n):

    yield sum(isinstance(i,int)for i in n)

    yield sum(isinstance(i,str)for i in n)

    yield sum(isinstance(i,float)for i in n)

    yield sum(isinstance(i,bool)for i in n)

    #yield is a generator object so we need to store the values in a container


    need suggestions and help


Log in to reply.

Original Post
0 of 0 posts June 2018