Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python count matching elements in a list

# Basic syntax:
sum(1 for item in your_list if item == "some_condition")
# This counts the items in your_list for which item == "some_condition"
#	is true. Of course, this can be changed to any conditional statement
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #python #count #matching #elements #list
ADD COMMENT
Topic
Name
3+5 =