A Lesson Learned in Keeping Things Simple.
For nearly three weeks I have been working on this basic counting problem. I have tried numerous attempts, all of which have resulted in either the code looping infinitely or resulting in breaks in the arithmetic that resulted in failed doctests for certain integer values.
Now that my brain has had time to process the logical flow of how Python handles each line of code, I have gained a sense of clarity that resulted in a simple solution for counting the number of even digits in an integer.
My initial attempts included the arithmetic needed to strip the integer being assessed within the “while” loop after the test for a positive integer. This resulted in the value being returned to be either 0, 1, or for the function to continuously loop. Once I realized that the while loop should be used to asses and count the number of even digits only, I was able to get the function to work better.
I then moved the logic around so that the integer argument was assessed first for a state of being positive or negative before stripping it down by a base of ten; the logic worked for most values.

This function would first check whether the integer n was even or odd. If even, 1 was added to the count. Else odd, it kept the count at its previous value. With each pass through the loop, n was being stripped down by a base of ten and the loop was repeated until the value of n was decreased to less than zero.
In order to anticipate the way in which the value of zero would be handled by this loop, a predetermined branch was needed to evaluate zero properly. Since zero % 2 == 0, zero had to be treated as an even integer and counted as 1 even digit:

Lastly, a doctest was ran against the function to ensure that it worked for a sample of values. So far so good.

While simple enough, this problem has helped me to really understand how straightforward Python is when handling the logical flow of a script.




I removed that space and then returned the value “5” to the right spot in the dockets parameters. 
![thedailywhat:
Genuine Happiness of the Day: Redditor TheLakesnapped this heartwarming photo of a Kenyan kindergartner who just finger-painted for the very first time.
They explain:
I took this photo while studying abroad in Kenya during the Spring of 2010. A few friends and I were about to climb Mt. Longonot when we stumbled upon a pre-primary (kindergarten) school. A week later we returned with school supplies for the 30+ students who attended the school. We have since started a non-profit organization to raise money to provide the children with a daily meal, school supplies, de-worming medicine, and a new school.
Thanks to the nonprofit, construction of a brand new school for the kids is scheduled to begin in January.
[reddit.]](http://24.media.tumblr.com/tumblr_ltzivhmpfd1qzpwi0o1_500.jpg)






