by CodeChum Admin
Looping a number and taking away each digit of it is so much fun, but I wanted to try out a much more complex task: getting the largest digit among them all.
Think you can handle the job?
Instructions:
a = int(input('Enter the number: '))
max = -1;
while a > 0:
if (max < int(a % 10)):
max = int(a % 10)
a /= 10
if max == -1:
print("Entered number should be > 0")
else:
print(max)
Comments
Leave a comment