# Scientific Computing with Python Projects - Arithmetic Formatter

Tell us what’s happening:
Hello, i’m starting with Python and I dont understand how to arrange my problem.

``````def split_list(x):
l = []
for i in x:
z = i.split()
for j in z:
l.append(j)
return(l)

def split_list_dig(x):
L = []
k = split_list(x)
for i in k:
if i == "+" or i == "-":
continue
else:
L.append(i)
return L

def arithmetic_arranger(x):
#Debut condition de fonctionnement
if len(x) > 5:
return "Error: Too many problems"
for i in range(len(x)):
if x[i].find("+") > 0 or x[i].find("-") > 0:
continue
else:
return "Error: Operator must be '+' or '-'"
for i in split_list_dig(x):
try:
z = int(i)
except:
return "Error: Numbers must only contain digits"
if len(i) <= 4:
continue
else:
return "Error: Numbers cannot be more than four digits"
digits = []
try:
for i in split_list_dig(x):
z = int(i)
digits.append(z)
except:
return "Error: Numbers must only contain digits"
#Fin condition de fonctionnement
#Debut calcul
Y = "-"
for i,j in zip(range(0,len(digits), 2), range(len(x))):
if x[j].find("+") > 0:
r1 = digits[i]
r2 = digits[i+1]
K1 = len(str(r1))
K2 = len(str(r2))
if K1 <= K2:
print(str(r1).rjust(2*K2," "))
print("+", str(r2).rjust(K2," ")) ; print(Y.rjust(K2+2,"-")) ; print("\n")
elif K1 > K2:
print(str(r1).rjust(2*K2," "))
print("+", str(r2).rjust(K2," ")) ; print(Y.rjust(K1+3,"-")) ; print("\n")
elif x[j].find("-")> 0 :
r1 = digits[i]
r2 = digits[i+1]
K1 = len(str(r1))
K2 = len(str(r2))
if K1 <= K2:
print(str(r1).rjust(6," "))
print("+", str(r2).rjust(K2," ")) ; print(Y.rjust(K2 + 2,"-")) ; print("\n")
elif K1 > K2:
print(str(r1).rjust(6," "))
print("+", str(r2).rjust(K2," ")) ; print(Y.rjust(K1,"-")) ; print("\n")

#Fin calcul
``````

User Agent is: `Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36`