Nov-08-2018, 09:23 PM
Hi,
I'm a total beginner and for class I have to change this while loop to a for loop and I just can't figure it out, help would be much appreciated.
It is a simple function to count the number of digits in a number. This is what I have.
Thanks
I'm a total beginner and for class I have to change this while loop to a for loop and I just can't figure it out, help would be much appreciated.
It is a simple function to count the number of digits in a number. This is what I have.
Thanks
def displayDigits(number): counter = 0 while(number > 0): number = number // 10 counter = counter + 1 print(counter) displayDigits(26)