Submitting my first assignment

Hi all,

Sorry if a dumb question, but I’ve just completed the lectures for my first course (Python For Everybody) and am working on my first assignment.

The code I have written responds as it is supposed to when I run it, but it generates a number of errors when I test it on Replit. I think this is just because I have approached it slightly differently to their solution, but the results are the same.

When you submit your projects is it all based on Replit accepting your solution? Do I have to make my code mirror the expected solution even if what I have works fine?

Thanks for any help,
Callum

I haven’t done the Python section (it was created after I did the curriculum.)

Replit is not doing the test. I assume is what happening is that you are submitting your link to FCC and FCC is running its own tests.

Will it fail the tests? That depends what the errors are. But in any case, you should figure out what the problem is - the goal is to become a good coder, not get away with doing as little as you can get away with.

If you have questions about various errors, ask the forum. Just keep the answers specific so you get good answers.

Yes, your project nereids to pass the tests . Post it if you need help in solving the issues

Thank you, see below. The problem is I can’t work out the issues as it behaves as expected for me!

def arithmetic_arranger(problems, args = None) :

    if len(problems) > 5 :
        return RuntimeError("Error: Too many problems.")

    firstNumber = []
    secondNumber = []
    answers = []
    width = []

    for sum in problems :

        part = sum.split()

        if (part[1] != "+") and (part[1] != "-") :
            return RuntimeError("Error: Operator must be '+' or '-'.")

        if (part[0].isnumeric() == False) or (part[2].isnumeric() == False) :
            return RuntimeError("Error: Numbers must contain digits.")

        if (len(part[0]) > 4) or (len(part[2]) > 4) :
            return RuntimeError("Error: Numbers cannot be more than four digits.")

        answer = eval(sum)

        lenFirstNum = len(part[0])+2
        lenSecondNum = len(part[2])+2
        lenMax = max(lenFirstNum,lenSecondNum)
        width.append(lenMax)

        firstNumber.append(part[0])
        secondNumber.append(part[1] + " " + part[2])
        answers.append(str(answer))

    var = 0
    one = ""
    for num in firstNumber :
        one += (num.rjust(width[var]))
        one +=  "    "
        var += 1

    var = 0
    two = ""
    for num in secondNumber :
        num = num.split()
        gap = width[var] - len(num[1]) - 1
        two += (num[0].rjust(0))
        two += (" " * gap)
        two += num[1]
        two += "    "
        var += 1

    var = 0
    three = ""
    for num in width :
        three += ("-" * (width[var]))
        three += "    "
        var += 1

    arranged_problems = one + "\n" + two + "\n" + three

    if args == True :
        four = ""
        var = 0
        for num in answers :
            four += (num.rjust(width[var]))
            four += "    "
            var += 1
        arranged_problems += "\n" + four

    return arranged_problems

print(arithmetic_arranger(["32 + 698", "3801 + 2", "45 + 43", "123 + 49","5 + 5"],True))`Preformatted text`

Please provide a link to your Replit, where you are running the code.
Especially the error messages are vital to see where any problem might occur.
For example, a typical mistake is trailing spaces in the arranged string - which ofcourse “look correct” to you, because spaces are not visible.

Seeing how you construct “four”, trailing spaces are almost certainly an invisible issue :wink:

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 (’).

the tests check what your function returns, I am not sure this will work with that