Hi, please i need some help as regards my code for the arithmetic formatter project

Tell us what’s happening:
Describe your issue in detail here.

import re

def arithmetic_arranger(problems, display=False): 

    # Too many problems error
    if len(problems) > 5:
        raise Exception("Too many problems.")

        # Operator error
for problem in problems:
    Prob = re.split(" ", problem)
    if '+' not in Prob or '-' not in Prob:
        raise Exception("Operator must be '+' or '-'.")

# Digit error
for problem in problems:
    Prob = re.split(" ", problem)
    if prob[problem][0].isdigit() is False or prob[problem][-1].isdigit is False:
        raise Exception("Numbers must only contain digits.")

# integer len error
    if len(problems[problem][0]) > 4 or len(problems[problem][-1]) > 4:
        raise Exception("Numbers cannot be more than four digits.")
for problem in problems:
if type(blocks[-1])==str:
            raise blocks[-1]

if display==True:
for i in range(count):
    for j in blocks:
    if j==blocks[-1]:
    raise arranged_problems[0:-1]

Your code so far

Your browser information:

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

Challenge: Arithmetic Formatter

Link to the challenge:

It really helps if you tell us what’s going on, what errors you are getting, etc. Without some info from you, you’re asking us to guess at possible problems and search every line of your code, but that is pretty slow.

At first glance, it looks like the indentation levels in your code are odd. I formatted your code, so I’m not sure if it looks like that for you, but it looks like some parts of your code are indented to be outside of your function.

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

Thank you for the reply. I will adjust the indentation, the errors i’m getting is problems not being defined, the preprocess i used not being defined and display not in use. Can i have opinions about the code generally, outputs and all??

Thank you, i will put this into consideration for my subsequent codes

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.