sum of digits of a number in python using while loop. #shorts

preview_player
Показать описание
sum of digits of a number in python using while loop. #shorts

sum of digits of a number in python using for loop

sum of numbers using while loop in python

sum of numbers in python using for loop

sum of digits of a number in python without loop

sum of digits in python programiz

sum of numbers using while loop in c

sum of digits of a number in c

@CodeWithShahrukh

#CodeWithShahrukh
#shortvideo
#youtubeshorts
#viralshorts
#short

sum of digits in python w3schools
Рекомендации по теме
Комментарии
Автор

Can't you just turn the int into a string and loop theough the digits?
It would look something like this:
def Sum(Input):
ToRerurn=0
for i in range(len(str(Input)):
ToReturn+=int(str(Input)[i])
return ToReturn

NOTE:
I haven't used python in a while, so the function str may be used incorrectly, or there may be a better way to turn it into a string

florianfilkohazi