Skip to content
Advertisement

print gives different output

I’m trying to make a 12×12 binary-puzzle game in python. There’s no GUI in the game, just the shell. To get the values of the tiles, I made an import function which imports values from an excel-document using xlrd. Now I’m making a function to print out the board, but something’s not quite right:

enter image description hereenter image description here

(sorry for too big pictures)

Here is my code:

Main:

JavaScript

Import:

JavaScript

Print:

JavaScript

I know it’s some inefficient code but its not stupid if it works(but it doesn’t work so it’s stupid)

tnx 4 helping!

EDIT: Tnx to @blorgon and @T1Berger, the issue is fixed, tnx guys!

Advertisement

Answer

You got a copy and paste error in every index space with str(d_[x][8])

As @blorgon pointed out you should refactor your code – with for the example a foreach loop going through the elements of your nested array. A simple list comprehension should do the trick and is easier to code and to understand:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement