Split number digits and add them.
(number: int)
| 19 | |
| 20 | |
| 21 | def split_and_add(number: int) -> int: |
| 22 | """Split number digits and add them.""" |
| 23 | sum_of_digits = 0 |
| 24 | while number > 0: |
| 25 | last_digit = number % 10 |
| 26 | sum_of_digits += last_digit |
| 27 | number = number // 10 # Removing the last_digit from the given number |
| 28 | return sum_of_digits |
| 29 | |
| 30 | |
| 31 | def solution(num: int = 100) -> int: |