Hi I have a question:
Write a function named avoids that takes a word and a string of forbidden letters, and that returns True if the word doesn’t use any of the forbidden letters.
The solution is :
avoids('word','o') gives me False which is correct!
avoids2('word','o') gives me True which is not correct!
WHY the avoids2 is not working correctly?
Write a function named avoids that takes a word and a string of forbidden letters, and that returns True if the word doesn’t use any of the forbidden letters.
The solution is :
def avoids(w,l): for j in w: if j in l: return False return TrueI know I can write this code in other ways as well but when I write :
def avoids2(w,l): for i in w: if i not in l: return True return FalseI get True every time!
avoids('word','o') gives me False which is correct!
avoids2('word','o') gives me True which is not correct!
WHY the avoids2 is not working correctly?