I am trying to count the number of digits of an input. However, whenever I input 10
or 11
or any two digit number, the output is 325
.
You must be using Python3, logically your function is right. You just have to change
countnumber = countnumber // 10
because Python3, // is floor division, meanwhile / is true division.
>>>print(1 / 10)
0.1
>>>print(1 // 10)
0
Btw, as @chrisz said above, you can just simply using the len() function to get the number of digits of the input
>>>print(len(input())