I am failing the tests and I don’t know how to fix these errors. Can someone help me?
Here is my code:
https://replit.com/@Autumn1055/boilerplatearithmeticformatter6#arithmetic_arranger.py
Take a look a the indentation in function. Remember in python indentation indicates which code blocks are together.
I noticed one thing: the number of problems can be up to five, and you have an error for >= 5 instead of just >5
The code is working now. Mistake you’ve made:
 No space betwen apostrofs when asigning empty variables;
top_lin = ""
mid_lin = ""
dash = ""
bottom_lin = ""

Should be just ‘>’:
if len(problems) > 5 :

Add
else
after if statement;
if len(problems) > 5:
return 'Error: Too many problems.'
else:
for _, prob in enumerate(problems):
a = prob.split()
part1 = a[0]
operator = a[1]
part2 = a[2]
 This statement
if operator != '+' or ''
won’t work because it’ll always beTrue
. Change to that;
if operator not in ('+', ''):
return "Error: Operator must be '+' or ''."
else:
 This statement
if a < len(problems)1
also won’t work , change to that;
if a != problems[1].split():
top_lin += " "
mid_lin += " "
dash += " "
bottom_lin += " "
 No need to compare True to True
if product == True:
, just do that;
if product:
arranged_problems = (top_lin + "\n" + mid_lin + "\n" + dash + "\n" + bottom_lin)
else:
arranged_problems = (top_lin + "\n" + mid_lin + "\n" + dash)
Now it should work.
Yes, I went through it line by line to make sure that I didn’t have any errors, but I am still getting the error
https://replit.com/@Autumn1055/boilerplatearithmeticformatter6#arithmetic_arranger.py
It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge.
you have only part of the problems, make sure that you are adding all of them to the final solution
I fixed my indentation, but I am still getting the same error.
https://replit.com/@Autumn1055/boilerplatearithmeticformatter6#arithmetic_arranger.py
How about reading the error message?
AssertionError: ' 123\n+ 49\n' != ' 3 3801 45 123\n+ 855 [53 chars]'
The error literally states that your output starts with “123” instead of “3” → 123 is the first number in the LAST problem.
Looking at the actual printed lines below, you’d notice the calculations that starts with “123” has only one problem, while the calculations starting with “3” have 4 problems in total.
In other words: You are only arranging the last problem of the set.
If I were you, I would copy and paste your code into Pycharm.
I had used Replit before and I did not like it.
Here is a hint from Pycharm:
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.