human
Count numbers having 0 as a digit | Returns 1 if x has 0 , else 0.
Traverse through all digits of x to check if it has 0..
If current digit is 0 , return true.
Returns count of numbers from 1 to n with 0 as digit.
Initialize count of numbers having 0 as digit ..
Traverse through all numbers and for every number check if it has 0..
Driver program"
How can the above be solved in Python?
 Give me a code to count numbers having 0 as a digit and the other steps required?
assistant
#Here is code to count numbers having 0 as a digit and the other steps required.
 def has0 ( x ) :
	while ( x != 0 ) :
		if ( x % 10 == 0 ) :
			return 1
		x = x // 10
	return 0
def getCount ( n ) :
	count = 0
	for i in range ( 1 , n + 1 ) :
		count = count + has0 ( i )
	return count
n = 107
print ( " Count ▁ of ▁ numbers ▁ from ▁ 1" , " ▁ to ▁ " , n , " ▁ is ▁ " , getCount ( n ) )