Answer the question
In order to leave comments, you need to log in
Why doesn't it work correctly?
a = int(input())
n = a % 10
a2 = a // 10
while(a2 != 0):
z = a2 % 10
if(n > z):
ld = n
else:
ld = z
a2 = a2 // 10
print(ld)
Answer the question
In order to leave comments, you need to log in
ld
It is desirable to declare a
variable before the loop. Wrong indentation
.
Too many unnecessary variables.
The algorithm itself is correct, but I would rewrite it like this:print
input_value = int(input())
max_number = 0
while (input_value > 0):
current_number = input_value % 10
if (max_number < current_number):
max_number = current_number
input_value //= 10
print(max_number)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question