How To Write A Count Function In Python