Im still new to python so ill try my best to explaining what I have done So basically my code asks the user for input it then imports a text file which contains words and each word is in a separate line, my code then store the users input in a separate file and only uses the first line of the user input I am trying to see if the words that my user input exists in the pre set text file I imported and then in my full code I would do some operations on that words but its not working i have tried using "==" and using "counter" and "if x in y...." and also if the user input does exist in text file the count on the last line prints zero.
user_input=input("Enter: ")
user_input=user_input.upper()
user_input=user_input.split()
print(user_input)
list_words=[]
with open("words.txt","r") as words:
english_words=words.readlines()
for line in english_words:
line=line.upper()
list_words.append(line.rstrip('\n'))
with open("user-message.txt","w+") as file_of_user_inp:
for word in user_input:
file_of_user_inp.write(word +"\n")
with open("user-message.txt","r") as file_of_user_inp:
first_line_user_inp=file_of_user_inp.readline()
user_input=first_line_user_inp
for each_eng_word in list_words:
for each_word in user_input:
if each_word==each_eng_word:
print("it worked")
print(list_words.count((user_input)))