[SOLVED]Perimeter defence help!

Hi @Anonym,
There’s only one mistake, but it’s repeated three times in your code. It’s to do with how for loops work.
Essentially for loops take thre inputs:
(start, end, step change)
But the weird thing is, the end number has to be one further (in the direction the for loop is going, up or down) than what you want it to run. This is because arrays start on zero. If you’re confused, I think reading my lengthy post here might help you a little bit more (it’s a very similar issue):

Also maybe read the rest of that thread.
Try this code and see what happens (just for testing don’t use this for the level):

# Let's say you want your hero to say the numbers 1-10:
for i in range(1, 10):
    hero.say(i)

#Output:
#1
#2
#3
#4
#5
#6
#7
#8
#9

Notice how your hero stops at 9? So if you want your hero to say 10 you’d do this:

for i in range(0, 11):
    hero.say(i)

So if you want to end at 80 on the first for loop you would go one further in the direction that the for loop is going in (this time it’s upwards) == 81.
Now see if you can do the other ones.
Danny

3 Likes