Help pls
3 Likes
can you send me your code?
1 Like
# You must defeat the ogres
# But they are using black magic!
# Only the highlander soldiers are immune.
# Find highlanders, their names always contain "mac"
highlanderName = "mac"
# This function should search for a string inside of a word:
def wordInString(string, word):
lenString = len(string)
lenWord = len(word)
# Step through indexes (i) from 0to (lenString - lenWord)
for i in range(0, lenString - lenWord):
# For each of them step through indexes (j) of the word length
for j in range(lenWord):
# If [i + j]th letter of the string is not equal [j]th letter of world, then break loop
if i + j != j:
break
'fuse'
# if this is the last letter of the word (j == lenWord - 1), then return True.
if (j == lenWord - 1):
return True
# If loops are ended then the word is not inside the string. Return False.
return False
# ∆ Remove this when the function is written.
# Look at your soldiers and choose highlanders only
soldiers = hero.findFriends()
for soldier in soldiers:
if wordInString(soldier.id, highlanderName):
hero.say(soldier.id + " be ready.")
# Time to attack!
hero.say("ATTACK!!!")
2 Likes
Can you refresh my memory I don’t remember this level can you post the link?
Charlie
3 Likes
the link for the level is here
1 Like