I am using python and coding a game where words have to start with the last letter of the word before, and I am trying to find a method to make my code look at a list of strings that have already been entered and choose a new word that is not one of those from a separate text file I already have set up. This is what I have so far but I am unsure what to do next. (Note: all of my checks for word viability other than if the word has been said previously work.)
def ai_choice(last: List[str]):
previous_word = last[-1]
f = open('english3.txt', 'r')
for line in f:
if line.lower().strip()[0] == previous_word[len(previous_word) - 1] and line != :
return True
else:
return False