>>> L = [[1, 2, 3], [1, 1, 1]]
>>> sum(x.count(1) for x in L)
4
More Related Contents:
- How to iterate through two lists in parallel?
- Transpose/Unzip Function (inverse of zip)?
- Iterating over every two elements in a list [duplicate]
- Are lists thread-safe?
- Python List vs. Array – when to use?
- How can I iterate through two lists in parallel?
- Getting a list of values from a list of dicts
- Pairs from single list
- Splitting a list based on a delimiter word
- What is the most pythonic way to pop a random element from a list?
- Naming conflict with built-in function
- Interleaving Lists in Python [duplicate]
- Does a slicing operation give me a deep or shallow copy?
- Confused about __str__ on list in Python [duplicate]
- join two lists of dictionaries on a single key
- Print LIST of unicode chars without escape characters
- Confusing […] List in Python: What is it?
- How to delete an item in a list if it exists?
- What is time complexity of a list to set conversion?
- Flattening a list recursively [duplicate]
- remove None value from a list without removing the 0 value
- Filtering a list based on a list of booleans
- Creating an empty list in Python
- Python: Remove Duplicate Items from Nested list
- Changing one dict changes all dicts in a list of dicts [duplicate]
- Python string.join(list) on object array rather than string array
- How to sort multidimensional array by column?
- sum each value in a list of tuples
- How do I send list of dictionary as Body parameter together with Files in FastAPI?
- deque.popleft() and list.pop(0). Is there performance difference?