Oct-28-2019, 12:48 PM
To give you some ideas: there are simple ways to sum digits in number.
For strings ('give me character converted into int for every character in string and sum'):
For strings ('give me character converted into int for every character in string and sum'):
>>> s = '123456' >>> sum(int(char) for char in s) 21For integer 'add reminder to total until there is no floor':
>>> num = 123456 >>> total = 0 >>> while num: ... num, reminder = divmod(num, 10) ... total += reminder ... >>> total 21
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.