add9 = []
add9.append(int(input("Enter 1st 4-digit no.: ")))
print(f"The answer will be 2 and {str(add9[0])[0 :-1]} and {str(add9[0]-2)[-1]} = 2{add9[0]-2}")
add9.append(int(input("Enter 2nd 4-digit no.: ")))
add9.append(9999-add9[1])
print(f"The 3rd 4-digit is 9999 - {add9[1]}= {add9[2]}")
add9.append(int(input("Enter 4th 4-digit no.: ")))
add9.append(9999-add9[3])
print(f"The 5th 4-digit is 9999 - {add9[2]}= {add9[4]}")
print(f"""
So,
{add9[0]}+{add9[1]} = {add9[0]+add9[1]}
{add9[0]+add9[1]}+{add9[2]} = {add9[0]+add9[1]+add9[2]}
{add9[0]+add9[1]+add9[2]}+{add9[3]} = {add9[0]+add9[1]+add9[2]+add9[3]}
{add9[0]+add9[1]+add9[2]+add9[3]}+{add9[4]} = {add9[0]+add9[1]+add9[2]+add9[3]+add9[4]}
""")
gives
Enter 1st 4-digit no.: 9999
The answer will be 2 and 999 and 7 = 29997
Enter 2nd 4-digit no.: 2345
The 3rd 4-digit is 9999 - 2345= 7654
Enter 4th 4-digit no.: 6789
The 5th 4-digit is 9999 - 7654= 3210
So,
9999+2345 = 12344
12344+7654 = 19998
19998+6789 = 26787
26787+3210 = 29997
[Program finished]
Code works fine. It's for kids to demo how to produce output using 3 inputs from user. The trick is to subtract 9999 from 2nd and 3rd input from user. I have tried to use as small syntax as possible.
Edit: 3rd and 5th digit are - 9999
Enter 1st 4-digit no.: 9990
The answer will be 2 and 999 and 8 = 29988
Enter 2nd 4-digit no.: 6667
The 3rd 4-digit is 9999 - 6667= 3332
Enter 4th 4-digit no.: 8888
The 5th 4-digit is 9999 - 3332= 1111
So,
9990+6667 = 16657
16657+3332 = 19989
19989+8888 = 28877
28877+1111 = 29988
[Program finished]
is working as expected
From calculator,
Calculation 1
(1/1) 9,990. +
(1/2) 6,667. =
(1/3) 16,657. +
(1/4) 3,332. =
(1/5) 19,989. +
(1/6) 8,888. =
(1/7) 28,877. +
(1/8) 1,111. =
(1/9) 29,988.