Question: The following code contains 5 errors. Identify the line number where the error occurs and provide a brief explanation of how to fix it .
The following code contains errors. Identify the line number where the error occurs and provide a brief explanation of how to fix it You do not need to add any additional lines or provide updated code.
from tkinter import Tk
from time import sleep
from random import randint as rand
window
window.titleThe window"
canvas Canvas window width height black"
numsquares inputHow many squares?"
square
colour red "yellow", "green", "blue"
for in rangenumsquares:
ccol rand
rand
rand
square.appendcanvascreaterectangle :fillcolour
canvas.pack
numsquares
numsquares
while True:
for in rangenumsquares:
pos canvas.coordssquarei
if pos or pos :
if pos or pos :
for in rangenumsquares
if : continue
pos canvas.coords square j
if pos pos and pos pos and pos pos and pos pos:
canvas,movesquare i
sleep
window. update
window mainloop
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
