Play Home Contribute GitHub Join Us Discourse Staff Members GitHub Contribution Guides Team



Hello. help with the task “second gem” in the desert. it seems the code is correct. after the second cycle, the gems no longer come out.

while True:
    items = hero.findItems()
    # Если длина массива больше или равна 2:
    if len(items)>=2:
        # Двигайся ко второму предмету массива.
        hero.moveXY(gem2.pos.x, gem2.pos.y)
    # Иначе:
        # Двигайся в центр.
        hero.moveXY(40, 33)


Please learn to post your code correctly. The way it is now, we can’t see the structure. Help us help you. It’s very easy to do and just takes a tiny bit of effort. Please read this topic and format your code again correctly


here did … and what’s the difference? why the first code didn’t work?
Mod edit: Please do not post successful solutions.


We do not post successful solutions on the board, as it interferes with learning. The difference between the first code and the second code is that in the first code you’re checking the second gem before the length of the gem is greater than or equal to 2. While in the second code, you are checking the second gem after the length of the gem is greater than or equal to 2.