I need help understanding what this error means. What causes this error?
Btw the code under the error message was just return False
also can someone please tell me what this comment wants me to do.
I need help understanding what this error means. What causes this error?
Btw the code under the error message was just return False
also can someone please tell me what this comment wants me to do.
This error occurs when you have an empty if-statement. You shouldn’t keep it empty, you can put pass
if you didn’t know what to do at that moment.
so we can help you, please can you post your code and specify which level this is
Highlanders
# 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 0 to (lenString - lenWord)
# For each of them step through indexes (j) of the word length
# If [i + j]th letter of the string is not equal [j]th letter of word, then break loop
# if this is the last letter of the word (j == lenWord - 1), then return True.
# If loops are ended then the word is not inside the string. Return False.
if break:
return False
return True # ∆ 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!!!")
this here requires you to use a for-loop
you should make another for-loop over here, inside the first one
once you finish those, we can add the other steps
‘break’ is a keyword in Python or pretty much any language, avoid using it as a variable.