def solve(): a = input() b = input() a_len = len(a) b_len = len(b) if a_len > b_len: b = '0' * (a_len - b_len) + b elif a_len < b_len: a = '0' * (b_len - a_len) + a mem = 0 res = "" for i in range(len(a)-1, 0-1, -1): x = int(a[i]) + int(b[i]) + mem mem = 0 if x >= 10: mem = 1 x = x % 10 res = str(x) + res if mem == 1: res = '1' + res print(res) solve()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | def solve(): a = input() b = input() a_len = len(a) b_len = len(b) if a_len > b_len: b = '0' * (a_len - b_len) + b elif a_len < b_len: a = '0' * (b_len - a_len) + a mem = 0 res = "" for i in range(len(a)-1, 0-1, -1): x = int(a[i]) + int(b[i]) + mem mem = 0 if x >= 10: mem = 1 x = x % 10 res = str(x) + res if mem == 1: res = '1' + res print(res) solve() |