for i in rnage(numberOfBears):
newbear = Bear()
x = random.randrange(myworld.getMaxX())
y = random.randrange(myworld.getMaxY())
while not myworld.emptyLocation(x,y):
x = random.randrange(myworld.getMaxX())
y = random.randrange(myworld.getMaxY())
myworld.addThing(newbear,x,y)
Showing posts with label Chapter 11. Show all posts
Showing posts with label Chapter 11. Show all posts
Wednesday, September 23, 2009
Chapter 11 Listing 11.12
The loop in lines 20 through 27 re-uses the newfish variable rather than a more correctly named newbear. the function still works properly but the variable name is confusing. Here is a corrected version of lines 20 -- 27.
Subscribe to:
Posts (Atom)