+ 3
is there any function to directly find greatest digit in a number in python
4 Respuestas
+ 2
You can convert to string, then to list and use the max function, like this:
num = 75482953
print(max(list(str(num))))
Its return 9
+ 7
Nathan Sikati You don't need to convert to a list. max() works on strings too.
print(max(str(num))) gives the same result. If you are just entering numbers,
print(max(input())) works 🙂
+ 3
There's nothing like that.
You need to break it down to individual digits, and then compare digit by digit.
You can refer the link below
https://www.google.com/amp/s/www.geeksforgeeks.org/largest-and-smallest-digit-of-a-number/amp/
+ 1
David Ashton i tried it, its works. Thanks👍