Avatar ·

Determination of the number with the largest sum of digits

📁 Advanced Python Topics

Three whole numbers are given. Determine which of them has the largest sum of digits. Organize the calculation of the sum of digits through a function.

I determine the sum of the digits of a number as follows:

   While  n & gt;  0 :  d = n% 10   n = n //  10    sum += d  

and how to organize it through a function?