Answers for "how to get how many data is in a list?"

2

how to check how many items are in a list python

list_a = ["Hello", 2, 15, "World", 34]

number_of_elements = len(list_a)

print("Number of elements in the list: ", number_of_elements)
Posted by: Guest on March-28-2021
1

python number of elements in list of lists

# Basic syntax:
# Using list comprehension:
sum([len(elem) for elem in list_of_lists])

# Example usage:
# Say you want to count the number of elements in a nested list like:
nested_list = [ [1, 2, 3, 45, 6, 7],
                [22, 33, 44, 55],
                [11, 13, 14, 15] ]

sum([len(elem) for elem in nested_list])
--> 14
Posted by: Guest on April-28-2021

Code answers related to "how to get how many data is in a list?"

Python Answers by Framework

Browse Popular Code Answers by Language