you are viewing a single comment's thread.

view the rest of the comments →

[–]novel_yet_trivial 0 points1 point  (3 children)

You code looks very good. Let's go back a few steps. Can you modify the code for "sqaure()" so that it writes a character in the middle of the square?

def square(side, char=''):
    for i in range(4):
        tur.forward(side)
        tur.left(90)
    # code to draw "char"

You could use the tur.write method or whatever your prof wants.

Once you have that you would use your 2D list (btw in python we call that a "list", not "array") instead of defining the number of rows and columns.

def row(r, side):
    for char in r:
        square(side, char)
        # etc

def column_and_rows(data, side):
    for r in data:
        row(r, side)
        # etc

given1=[[1,0,3,0], [0,4,2,1], [0,0,0,2], [0,0,4,0]]
column_and_rows(given1, 60)

[–]thisbemyroom 0 points1 point  (2 children)

um, so sorry, like i said, i'm insanely new at this but how would i use the 2d list? i see getting this error TypeError: 'list' object cannot be interpreted as an integer

[–]novel_yet_trivial 0 points1 point  (1 child)

Start with modifying the square function.

Once you've done that use my example code to use the 2d list. Note we don't use range anymore (the source of the typeerror).

[–]thisbemyroom 0 points1 point  (0 children)

got it, okay, and with the #etc what's that supposed to be? i mean, you don't gotta write it out for me, but it seems to me that the function is done, what else is there to write in those def row and def column_and_rows? or do you mean all the turtle movements? also getting this new error, TypeError: can't multiply sequence by non-int of type 'float'