I am trying to do the echo of war level. I’m trying to use the string.contains() method but am getting the following error (I know I could do this by iterating through the characters of the string in a loop but I want to understand why the string.contains() is not working)
This is the error message I am getting
Here is my code.
# Destroy 5 robobombs. Some of them are old and safe. # Old (safe) bombs have the certain letter in their id. # This function checks if searchLetter is in searchWord. def isLetterInWord(searchWord, searchLetter): # Complete the function. if searchWord.contains(searchLetter): return True return False # The engineer knows how the old robots are marked. engineer = hero.findFriends() safeLetter = engineer.safeLetter enemies = hero.findEnemies() for index in range(len(enemies)): enemy = enemies[index] if enemy and isLetterInWord(enemy.id, safeLetter): # Destroy the enemy if it's safe. while enemy.health > 0: hero.attack(enemy)
I want to know what I’m doing wrong with contains not an alternative solution to the problem please (which I know how to do)