-3

enter image description here

this code run on my command line, total of 6 test and it failed two.it looks like extra space and i cant figure out how to solve it.

here is the link to my repl https://repl.it/@seunlaww/SnivelingWateryArchives-1#arithmetic_arranger.py

seunlaw
  • 3
  • 1
  • Welcome to Stack Overflow! Please take the [tour] and read [ask]. You should provide your code and errors as [formatted text](/help/formatting) in your question instead of an image, so that people can copy it and search engines can index it for others with the same problem to find in the future. Also, read [how to debug small programs](https://ericlippert.com/2014/03/05/how-to-debug-small-programs/) and narrow down the problem into a [mre]. – Pranav Hosangadi Sep 22 '20 at 16:12

1 Answers1

0

Two issues:

  • On line 2, remove an extra space
  • In the length check, use len(problems), not len(problem)

Here is the updated code:

line1 += num1.rjust(space)
        line2 += op + num2.rjust(space-1)  # remove extra space
        line3 += "-" * space
        line4 += str(result).rjust(space)
        if z < len(problems) - 1:   # use problems, not problem
            line1 += extra_space
            line2 += extra_space
            line3 += extra_space
            line4 += extra_space

All the tests pass with these changes.

Mike67
  • 11,175
  • 2
  • 7
  • 15