Help with challenge level wrong type

hi here s my code have been at it for a while but my character just stands there then runs of screen

# Only attack enemies if their `type` is "munchkin".
while True:
    enemy = hero.findEnemies()
    for enemy and enemy:
        if enemy and enemy.type == "munchkin":
            hero.attack(enemy)

I believe it should be hero.findEnemy() and not hero.findEnemies()

did that but now the error says that there still is a problem

while True:
    enemy = hero.findEnemy()
    for enemy and enemy:
        if enemy and enemy.type == "munchkin":
            hero.attack(enemy)

I think you should delete for enemy and enemy:

Its the forest, you don’t learn that yet

also it is not hero.findEnemy() it is hero.findNearestEnemy()

I also forgot that lol. A bit rusty in this

P.S. Vanessa is right you do not learn that until mountain.

One question: have you been looking at other peoples code?

waitwaitwaitwait he might be sub who skipped the extra levels @Vanessa

1 Like

so i deleted that and it brought up an error and told me to change it to enemies

while True:
    enemy = hero.findEnemies()
    if enemy and enemy.type == "munchkin":
        hero.attack(enemy)
 

but my hero wont move at all

what level is this?
nvm

that is an array finding method, use hero.findNearestEnemy()

Its hero.findNearestEnemy()not Enemies

hero.findEnemies()

Did they change it?

200000

hero.findEnemies()

this is a array finding method

1 Like

is what i meant to say

i changed it to

while True:
    **enemy = hero.findNearestEnemy()**
    if enemy and enemy.type == "munchkin":
        hero.attack(enemy)

``
and it worked thank you for all your help guys its much appreciated:smiley: :smiley: :partying_face: :tada:
1 Like

thank you all guys :tada: :partying_face: :smiley:

you are welcome @Cruz_aid