Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Newbie with problem to understand the difference
-
In this program i want to develop a Matrix of a Solitär playfield.
I could not find the difference if I want to began at the base line with MatrixFeld[0,0][202020202 020202020 002020200 000202000 000020000]
It gives me an error if j = 0 but not if began at j = 1
For me there is no difference.
WHO could give me help.
Thank you.
Christophimport numpy as np def main(): spielFeld = int( input('Länge des Spielfelde') ) nullFeld = 0 freiesFeld = 1 belegtesFeld = 2 maxx=spielFeld maxy= spielFeld // 2 + 1 Feld = np Feld.shape = (maxy, maxx) FeldMatrix = np.zeros(Feld.shape) j = 0 '''for j in range(0, maxy):''' for i in range(j, maxx-j, 2): FeldMatrix [j,i] = freiesFeld FeldMatrix [j,i+1] = nullFeld j = 1 for i in range(j, maxx-j, 2): FeldMatrix [j,i] = freiesFeld FeldMatrix [j,i+1] = nullFeld j = 2 for i in range(j, maxx-j, 2): FeldMatrix [j,i] = freiesFeld FeldMatrix [j,i+1] = nullFeld j = 3 for i in range(j, maxx-j, 2): FeldMatrix [j,i] = freiesFeld FeldMatrix [j,i+1] = nullFeld j = 4 for i in range(j, maxx-j, 2): FeldMatrix [j,i] = freiesFeld FeldMatrix [j,i+1] = nullFeld print(FeldMatrix) if __name__ == '__main__': main()
-
@Bombastino It seems that the indentation of these lines is not correct:
for i in range(j, maxx-j, 2): FeldMatrix [j,i] = freiesFeld FeldMatrix [j,i+1] = nullFeld