Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

[SOLVED] By Any Other Name - Python

Hello,
I can not solve the problem " By Any Other Name"
I have searched the way to solve it in forum but It still does not work.
Please help me.

A couple things:
This should probably be posted in level help and not bugs.
Please post your code so that we can help you, and give more detail of what exactly isn’t working.
I don’t subscribe so I can’t help with the level, but this might help:
By Any Other Name help

1 Like

Hi,
It is a bug, sure. Because my code is exactly correct , but the gems are still not available.

enemy1 = “gemDude1”
gemDude1 = hero.findNearestEnemy()
hero.attack(gemDude1)
hero.attack(gemDude1)

enemy2= “gemDude2”
gemDude2 = hero.findNearestEnemy()
hero.attack(gemDude2)
hero.attack(gemDude2)

hero.moveUp()
hero.moveRight()
hero.moveRight()

Your code is essentially correct, but the two lines with enemy# = “gemDude#” don’t need to be there and are causing a problem. You changed the name of the variable correctly with the rest of the code. You don’t need to assign the word “gemDude1” to the variable enemy1. The level won’t pass if it sees the variables enemy1 or enemy2 since you are supposed to change them. That’s the lesson of this level, so it isn’t quite a bug.

1 Like

The level won’t pass if it sees the variables enemy1 or enemy2 - Yes :slight_smile:
enemy1 = anything ( null, number, string) the left half of the fence will stay and enemy2 = anything so will the right half.
But I’m curious - why this sadist works for all numbers < 17 ( H_ng_Le equipment) ?

max = 17
n = 0
p = 0
gemDude1 = hero.findNearestEnemy()
while n < max:
    hero.attack(gemDude1)
    n += 1
# same for the second enemy

The above code will work with a warrior and the Sword of the Temple Gard with max = 19
The question is serious - why?

Tks all for your support
I understood and I solved the problem. :sunny: