Still, output should be '1 + 2 + 3 + 4 = 10' or just '10'?
You can have this way:
You can have this way:
>>> a = '1234' >>> b = list(a) >>> total = sum([int(x) for x in b]) >>> f"{' + '.join(b)} = {total}" '1 + 2 + 3 + 4 = 10'Or just sum:
>>> a = '1234' >>> sum([int(x) for x in list(a)]) 10
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.