Question: Here is my code

```
#Chose Grid size
m = int(input("Enter the width and length of the Grid: ",))
n = m
print("Your Grid will be",m,"x",n)
Grid = np.zeros((m+2,n+2))
#Grid filling in
i = 0
while(i <= 5*m):
    i = i+1
    Grid[randint(1,m), randint(1,n)] = 1
img = pl.imshow(Grid, cmap = 'PuRd', interpolation = 'none')

SecGrid = np.zeros((m+2,n+2))
SecGrid = Grid

#Main
for i in range(1,m):
    for j in range(1,n):
        #Nbr of entities
        nbr = 0
        for k in range(-1,1):
            for l in range(-1,1):
                nbr = nbr + Grid[i+k,j+l]
        #cells that are alive
        if Grid[i,j] == 1:
            if nbr > 1 and nbr < 4:
                then SecGrid[i,j] = 1
                else SecGrid[i,j] = 0
            #cells that are dead
            else:
                if nbr == 3:
                    then SecGrid[i,j] = 1
                    else SecGrid[i,j] = 0

```

And here is my error 

```
  File "/Users/tryotest/Downloads/GameOfLife.py", line 32
    then SecGrid[i,j] = 1
               ^
SyntaxError: invalid syntax

```

Answer: 
You're doing the `if...else` wrong. Here's the corrected code:

```
#Chose Grid size
m = int(input("Enter the width and length of the Grid: ",))
n = m
print("Your Grid will be",m,"x",n)
Grid = np.zeros((m+2,n+2))
#Grid filling in
i = 0
while(i <= 5*m):
    i = i+1
    Grid[randint(1,m), randint(1,n)] = 1
img = pl.imshow(Grid, cmap = 'PuRd', interpolation = 'none')

SecGrid = np.zeros((m+2,n+2))
SecGrid = Grid

#Main
for i in range(1,m):
    for j in range(1,n):
        #Nbr of entities
        nbr = 0
        for k in range(-1,1):
            for l in range(-1,1):
                nbr = nbr + Grid[i+k,j+l]
        #cells that are alive
        if Grid[i,j] == 1:
            if nbr > 1 and nbr < 4:
                SecGrid[i,j] = 1
            else:
                SecGrid[i,j] = 0
            #cells that are dead
            else:
                if nbr == 3:
                    SecGrid[i,j] = 1
                else:
                    SecGrid[i,j] = 0

```
As the error (`SyntaxError`) suggests, your syntax is wrong. In Python, if statements are constructed as `if ... else ...` For more info on the if statement, follow the link.

<https://docs.python.org/2/tutorial/controlflow.html>

More generally, I suggest going through a general tutorial for Python in order to get the hang of the overall syntax.