Why is there a different output in turtle and in console


Here’s my code: I was wondering why I get different outputs in my console and in the turtle module. how would I fix this so that the indentation in the turtle window is correct and lines up in the same column?

import turtle

y = 180
for i in range(1, 9 + 1):
string = “”
#string += str(i) + " |"

for j in range(1, 9 + 1):
    string += format(i * j, ">4d")

if i > 0:

turtle.goto(-40, y)
turtle.write(string, font=("Arial", 20, "normal"))
y -= 20



Ignore the comment. The only thing that matters is the outputs.


Please make sure that your code is intact. It should be possible to copy it and run it without any modification.

I’m not sure what your different outputs are. You’ll have to show/tell.

What comment should we ignore? The commented out line in the code? You can edit your post and remove it instead.

Are you trying to align numbers? You can accomplish that by making sure each number has the same width, which involves adding spaces where they are not wide enough. (padding)
Another requirement is to use a fixed-width font. A number 1 should be as wide as the number 0, for example.


How would I make each character a fixed width font?


Change to a font with that property, for example inconsolata


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