I'm trying to make a function that will take an argument that's a word (or set of characters) as well as the speech, and return a boolean expression saying whether the word is there or not, as a function.
speech2 = open("Obama_DNC.txt", "r")
speech2_words = speech2.read()
def search(word):
if word in speech2_words:
if len(word) == len(word in speech2_words):
print(True)
elif len(word) != len(word in speech2_words):
print(False)
elif not word in speech2_words:
print(False)
word = input("search?")
search(word)
I want to make it so that the word that the program searches for in the text matches exactly as the input and that are not a part of another word ("America" in "American"). I thought of using the len() function but it doesn't seem to work and I am stuck. If anyone helps me figure this out that would be very helpful. Thank you in advance
Aucun commentaire:
Enregistrer un commentaire