I would greatly appreciate if someone could explain why I'm getting a syntax error for the line with the else statement.
x = 0
digits = 0
while(x != 0):
x = x // 10
digits += 1
print(digits)
else(x == 0):
print(1)
I have to create a code that uses a while loop and conditional statement in which it assess the number of digits an integer contains. The else loop is needed otherwise if I have x = 0, it will print 0 as the no. of digits which is of course false.