Convoluted logic –
in the for loop
for friend in friends:
if hero.time < 3.5:
...
elif friend.type == "archer": # AND if hero.time >= 3.5
...
elif friend.type == "paladin":
...
elif friend.type == "soldier":
...
Clear logic would be something like this:
if hero.time < 3:
...
elif hero.time < 10:
...
elif hero.time < 20:
...
else: # when hero.time >= 20
...
And then somewhere inside those statements, you can determine what to do depending on friend.type
.
regarding the while loop
while hero.time < 20:
friends = hero.findFriends()
for friend in friends:
...
# end of while
# ok, so what do you do after the 20-second mark?
Also, I’d suggest making functions for those pieces of code that repeat inside your program.
Useful tips on organizing your code for clarity: