Sarven Sum Help!

Hi everyone,
Struggling with the level, I can not see what is wrong… In this level, there’s some fire-traps and the goal is to add the minimum and maximum values of the fire-traps and “say” it at the cross position. I used a “while hero.time < 5” in order to have a while-loop for the fire-trap thing and then doing something else.

while hero.time < 5:
    trapIndex = 0 
    trapValm = 900
    trapValp = 0
    wtrap = None
    strap = None
    traps = hero.findByType("fire-trap")
    while trapIndex < traps :
        trapm = traps[trapIndex] 
        if trapm.value < trapValm :
            wtrap = trapm
            trapValm = trapm.value
               
        trapp = traps[trapIndex] 
        if trapp.value > trapValp :
            strap = trapp 
            trapValp = trapp.value
        trapIndex +=1 
    val = strap.value + wtrap.value
    hero.moveXY(27, 42)
    hero.say(val)

I don’t know how to have the value retain.
Thanks for your help :slight_smile:
(sorry if there’s some english mistakes, I’m French)

Welcome to the discourse @Funkyskanga :partying_face:

Dont worry your english is amazing :slight_smile:

Try making this len(traps)

I will further look into the code once im free if the above doesnt solve it :slightly_smiling_face:

3 Likes

I can’t believe I did a mistake like that haha ! I think I was looking to close in the code, scratching my head because I couldn’t understand where I did a mistake and it was just a “miss” of the “len” haha !
I would say basic code error : always look first for the easiest mistake !
Thanks a lot for the answer :wink:

2 Likes

Indeed, very true

You’re most welcome :smile:

If you passed the level, it would be appreciated if you would please mark the solution as a solution so the topic can close, thanks :]

1 Like

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.