flag = 0 for i in range(-1, -length2 - 1, -1): temp = int(num1[i]) + int(num2[i]) + flag flag = 1if temp > 9else0 result = str(temp % 10) + result for i in range(-length2 - 1, -length1 - 1, -1): temp = int(num1[i]) + flag flag = 1if temp > 9else0 result = str(temp % 10) + result if flag: result = str(flag) + result return result