Помогите пожалуйста пройти уровень Хрупкий Боевой Дух(Python)

Вместо одной цифры герой говорит 625

У тебя есть только один выстрел, но это должен быть смертельный выстрел.

Функция должна возвращать наиболее здорового (health) врага.

def findStrongestEnemy(enemies):
strongest = None
strongestHealth = 0
enemyIndex = 0
# Пока счетчик (enemyIndex) меньше чем длина массива врагов (len(enemies))
while enemyIndex < len(enemies):
# присвой переменной enemy значение элемента массива врагов enemies[enemyIndex]
enemy = enemies[enemyIndex]
# если здоровье врага (enemy.health) больше чем наибольшее
if enemy.health > strongestHealth:
# назначь переменной strongest более “здороового” врага (enemy)
# не забудь переписать strongestHealth новым значением наибольшего здоровья врага enemy.health
strongest = strongestHealth
strongestHealth = enemy.health
# бездонные циклы никому не нужны (: >>>увеличивай счетчик enemyIndex
enemyIndex += 1

return strongest

enemies = hero.findEnemies()
leader = findStrongestEnemy(enemies)
if leader:
hero.say(leader)

please format your code properly according to the codecombat forum FAQ.

Переводчик для чайников
search button -> search topics, posts, users, or categories: Brittle Morale

@MunkeyShynes we need ur canned post

Please learn to post your code properly. It’s really easy and only requires a very small amount of effort.

To post your code from the game, use the </> button or it won’t format properly. When you click the </> button, the following will appear:

Please paste ALL of your code inside the triple back tick marks.

``` <— Triple back tick marks.

Paste ALL of your code in here.

``` <— Triple back tick marks.

There are many people here willing and able to help. If you use the </> button correctly, then ALL of your code should look like this:

while True:
    enemy = hero.findNearestEnemy()
    if enemy:
        hero.attack(enemy)
    else:
        hero.say("My code is formatted properly")

If ALL of your code isn’t formatted like the code above, then you’re doing it wrong and we can’t see the structure of the code to troubleshoot whether or not that is the issue. Use the </> button and help us help you. This works when sending a private message as well.

Thank you.

Boom!

Пожалуйста, не публикуйте такие решения. Это противоречит правилам дискурса, а дискурс является средой обучения.

Please don’t post solutions like that. It’s against discourse rules and the discourse is a learning enviorment.

It’s not a solution.
The name is randomised when you click submit, so that method would only work when you click run (it doesn’t change when you click run), therefore this code won’t actually help you to pass the level.

2 Likes

oh okay :sweat_smile: (20 charsssssss)