Mad Maxer: Redemption
I know my code is bad. I’ve been struggling with array’s. I’ve been trying to learn how to code for almost a year now and arrays have killed my progress every time.
I’ve been reviewing the other levels, reading the forum and I’ve saved my code so I can look at what I’ve done on other levels. This is a mixture of my code from two other levels: ‘mad maxer strikes back’ and ‘sarven savior’.
details=xyz [/details didn’t work inside the 3 back ticks so i put that code after the back ticks so if it doesn’t line up I didn’t know how else to post without having all the code showing. Any advise on how to do that properly will be helpful as well.
I am a subscriber but I posted here because maybe this topic will help others as well.
loop:
weakestFriend = None
leastHealth = 9999
# This should create an array of all friends
friends = self.findFriends()
# Array indices start at 0
friendIndex = 0
# Loop over each name in the array.
# The len() function gets the length of the list.
while friendIndex < len(friends):
# Use square brackets to get a name from the array.
friend = friends[friendIndex]
# Increment the index to get the next name from the array.
friendIndex += 1
code
if friend.health < leastHealth:
friend.health = leastHealth
weakestFriend = friend
# Tell your friend to go home. Use + to connect two strings.
code
if friend:
if friend.type != "archer":
self.say('Hey ' + weakestFriend.id + ', go home!')