in my code, the line i highlighted cannot run and it says TyperError: need an object, im not sure what i need to do to fix my code.
here is my code.
# There are four pairs of twins, they should pray by pairs.
# You need to find twins and call them.
# Twins have the same names, only the last letter is different.
# This function checks if the pair of units are twins.
def areTwins(unit1, unit2):
name1 = unit1.id
name2 = unit2.id
if name1.length != name2.length:
return False
for i in range(name1.length - 1):
if name1[i] != name2[i]:
return False
return True
# Iterate over all pairs of paladins and
# say() their name by pairs if they are twins.
twins = hero.findFriends() # <--------------------- here is my problem/error
for i in len(twins) :
for j in len(twins) :
if i != j and areFriends(twins[i], twins[j]) :
hero.say(twins[i].id + " " + twins[j].id)
# For example: hero.say("NameTwin1 NameTwin2")
hero.moveXY(64, 36)
hero.moveXY(14, 36)
# When twins are in their spots, lure the ogre.
# Don't be afraid of beams - they are dangerous only for ogres.