This is a check digit exercise.
A=str(56784321)
for x in [0,2,4,6]:
B = int(A[x])*2
if len(str(B))==2:
B = int(str(B)[0])+int(str(B)[1])
print (B)
Output:
1
5
8
4
How can I use further code to add 4 of them together?