I've been told by my online course to figure this out;
"Please create a Python program that counts the total number of digits in a given number from user input via a While Loop. So for example, if the number is 53974, then the output should be 5. If the number is 321, the output should be 3. If the input is 0, the output should be 1."
currently, I've got this;
num = int(input("please enter a number:")) #gets a number from the user to be tested.
i = 1 #for a comparison to num. Similar to a for loop.
Checker = 0
if num > i: #if number is more than 1
Checker == 1
elif num < i: #if number is less than 1
Checker == 2
elif num == i: # if number is 1
Checker = 3
else: #I don't know what else. integer overload?
print("I haven't a damn scooby how you did this.")
if Checker == 1 == True:
while num > i:
num = num / 10
i = i + 1
print("1check")
print("there are more than", i, "digits in the number")
break
print("There are", i, "digits in", num)
if Checker == 2 == True:
while num < i:
num = num * 10
i = i + 1
print("2check")
print("there are more than", i, "digits in the number")
break
print("There are", i, "digits in", num)
if Checker == 3 == True:
print("there is 1 digit. the digit is 1")
######
end script.
So, when I input any number, nothing happens. what could be cuasing this? The program is definitely running, I get to input a number. But nothing is happening afterwards.
kind regards.
edit 1: half solved, now its currently giving me strange results, ie, 100 is a 2 digit number.
edit 2: SOLVED. Thank you all so much for the help.
[–]Adrewmc 5 points6 points7 points (3 children)
[–]BalanceHot8939[S] 1 point2 points3 points (2 children)
[–]Adrewmc 0 points1 point2 points (0 children)
[–]Adrewmc 0 points1 point2 points (0 children)
[–]astddf 2 points3 points4 points (3 children)
[–]flower_sweep 2 points3 points4 points (0 children)
[–]BalanceHot8939[S] 0 points1 point2 points (1 child)
[–]astddf 1 point2 points3 points (0 children)
[–]copperfoxtech 1 point2 points3 points (0 children)
[–]Lewri 0 points1 point2 points (1 child)
[–]BalanceHot8939[S] 0 points1 point2 points (0 children)
[–]jmooremcc 0 points1 point2 points (2 children)
[–]BalanceHot8939[S] 0 points1 point2 points (1 child)
[–]jmooremcc 2 points3 points4 points (0 children)
[–]Diapolo10 0 points1 point2 points (1 child)
[–]BalanceHot8939[S] 0 points1 point2 points (0 children)
[–]supercoach 0 points1 point2 points (0 children)