Counting number of digits of input using python
问题 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 . Why doesn't it work? inputnumber = int(input()) countnumber = inputnumber digitcount = 0 while countnumber > 0: digitcount += 1 countnumber = countnumber/10 print(digitcount) # result is 325 when input is 10 or 11 回答1: Your error mainly happened here: countnumber=countnumber/10 Note that you are intending to do integer division. Single-slash division in Python