Skip to content

Use Count

Documentation Index

Fetch the complete documentation index at: https://docs.sourcery.ai/llms.txt

Use this file to discover all available pages before exploring further.

Replaces sum() with count() where appropriate

return sum(hat == "bowler" for hat in hats)
return hats.count("bowler")

This simplification can be made where a call to sum() is counting the number of elements that match a condition.