Consider an array/list of sheep where some sheep may be missing from their place. We need a function that counts the number of sheep present in the array (true means present).
For example,
[True, True, True, False,
True, True, True, True ,
True, False, True, False,
True, False, False, True ,
True, True, True, True ,
False, False, True, True]
The correct answer would be 17.
This is what I tried:
def count_sheeps(sheep):
total = 0
for i in sheep:
if i == 'True':
total += i
else:
return None
This code throws up an error saying that None should equal 17.