Scientific Computing with Python Projects - Arithmetic Formatter

Tell us what’s happening:
Describe your issue in detail here.
Im stuck i dont know what is wrong with this line:
if re.search(“[/]”, problem) or re.search(“[*]”, problem):

Your code so far
import re

def arithmetic_arranger(problems):
#we want this
# [“32 + 698”, “3801 - 2”, “45 + 43”, “123 + 49”]

# to look like this
 # 32         1      9999      523
 #+  8    - 3801    + 9999    -  49
 #----    ------    ------    -----
 #40     -3800     19998      474
if(len(problems) > 5):
  return "Error: Too Many Problems."
  
a = ""
b = ""
lin = ""
add = ""
string = ""
for problem in problems:
  if(re.search("[^\s0-9.+-]"), problem):
    if re.search("[/]", problem) or re.search("[*]", problem):
      return "Error: Operator must be '+' or '-'."
    return "Error: Numbers must only contain digits."

number1 = problem.split(" ")[0]

op = problem.split(" ")[1]
number2 = problem.split(" ")[2] 

if(len(number1) >= 5 or len(number2) >= 5):
  return "Error: Numbers cannot be more than four digits."


sum = ""
if(op == "+"):
  sum = str(int(number1) + int(number2))
elif(op == "-"):
  sum = str(int(number1) - int(number2))

length = max(len(number1), len(number2)) +2
t = str(number1).rjust(length)
bot = op + str(number2).rjust(length - 1)
lin = ""
res = str(sum).rjust(length)  
for s in range(length):
  lin += "-"

if problem != problems[-1]:
  a += t + '    ' 
  b += bot + '    '
  line += lin + '    '
  add += res + '    '
else:
  a += t
  b += bot 
  line += lin
  add += res

if solve :
    string = a + "\n" + b + "\n" + lin + "\n" + add
else:
    string = a + "\n" + b + "\n" + lin

return string

Your browser information:

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

Challenge: Scientific Computing with Python Projects - Arithmetic Formatter

Link to the challenge:

So what error are you getting?

At a quick glance, it seems that “, problem” in the below line is supposed to be inside the re.search function and isn’t.

 if(re.search("[^\s0-9.+-]"), problem)