+ 3
Counting value in List
If a list contains False, how can I count value 0 without counting False?
5 Respostas
+ 4
False is evaluated as 0, so if you write
n==0
False will be removed as well.
Instead use:
n is 0
False may equal 0, but it is not itself the number 0.
+ 3
Check this
It uses type() to check whether it is integer or not...
https://code.sololearn.com/cN19VPZsyqFP/?ref=app
+ 3
a = [0, 1, False, 0]
a.count(0) # 3
len([x for x in a if x is 0]) # 2
0
i don’t quite understand your question. can you provide your code so that people can see and provide an answer.
0
thank you guys.