True
is equal to 1
.
>>> sum([True, True, False, False, False, True])
3
More Related Contents:
- Find the item with maximum occurrences in a list [duplicate]
- Python AND operator on two boolean lists – how?
- Python Bool and int comparison and indexing on list with boolean values
- Empty list boolean value
- What does += mean in this context?
- How to name a file using a value in a list in a dictionary?
- What does “list comprehension” and similar mean? How does it work and how can I use it?
- Why does append() always return None in Python? [duplicate]
- Convert all strings in a list to int
- Get unique values from a list in python [duplicate]
- Element-wise addition of 2 lists?
- Sum a list of numbers in Python
- List comprehension vs generator expression’s weird timeit results?
- Modify a list while iterating
- How do I loop through a list by twos? [duplicate]
- converting a list of integers into range in python
- How to make a set of lists
- How can I find same values in a list and group together a new list?
- What’s the difference between lists enclosed by square brackets and parentheses in Python?
- Difference between using [] and list() in Python
- TypeError: ‘float’ object is not subscriptable
- Python .sort() not working as expected
- Fastest way to count number of occurrences in a Python list
- Creating a dictionary with list of lists in Python
- How to zip two lists of lists
- How to create a number of empty nested lists in python [duplicate]
- How can I sort a list, according to where its elements appear in another list?
- Size of a Python list in memory
- Iterate a list with indexes [duplicate]
- Comparing 2 lists consisting of dictionaries with unique keys in python