Python Forum
Usborne Coding for Beginners using Python 'Dodge the Bombs' Syntax Error
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Usborne Coding for Beginners using Python 'Dodge the Bombs' Syntax Error
#1
I am working through a coding book with my child and we cannot figure out why we are getting errors. We have written other code using IDLE where we have imported tkinter and it has worked on our laptop.
Here is our code so far
 import tkinter
import random
gameOver = False
score = 0
SquaresToClear = 0
def play_bombdodger():
    create_bombfield(bombfield)
    window=tkinter.TK()
    layout_window(window)
    window.mainloop()
bombfield = []
def create_bombfield(bombfield):
    global squaresToClear
    for row in range(0,10):
        rowList=[]
        for column in range(0,10):
            if random.randint(1,100) < 20:
                rowList.append(1)
            else:
                rowList.append(0)
                squaresToClear = squaresToClear + 1
        bombfield.append(rowList)
    printfield(bombfield)
def printfield(bombfield):
    for rowList in bombfield:
        print(rowList)
def layout_window(window):
    for rowNumber, rowList in enumerate (bombfield):
        for columnNumber, columnEntry in enumerate (rowList):
            if random.randint(1,100)<25:
                square=tkinter.Label(Window, text="    ",bg= "darkgreen")
            elif random.randint(1,100)>75:
                square=tkinter.Label(window, text= "    ", bg = "seagreen")
            else:
                square = tkinter.Label(window,text="    ", bg="green")
            square.grid(row.grid(row=rowNumber,column=columnNumber)
            square.bind("<button-1>", on_click)
play_bombdodger()
Basically nothing is happening for us. We are not seeing a map of bombs in the shell window, and we are also not getting a square of green shades. We are reluctant to proceed further with making this game because of the errors.
Reply


Messages In This Thread
Usborne Coding for Beginners using Python 'Dodge the Bombs' Syntax Error - by CMSheWolfe - May-24-2020, 12:08 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Database Submit Entry Syntax Error Melford 27 7,825 Jan-27-2020, 04:20 PM
Last Post: Denni

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020