I am learning how to program in python for school and I apologize if my question is very basic. But I am attempting to have python read a txt file on my macbook that is called word.txt for an exercise for a book called think_python for class. Below is the code I am attempting to use to have the file read by python
import os
f = open(os.path.expanduser("~/Downloads/word.txt"))
f.readlines()
I then run the in function to try and have python see if the word "uno" is in the word.txt file.
"uno" in f
Python returns the in function as false, but I do have the word as "uno" in the text file, I have also tried removing the quotes and just uno in the txt file and same result. The assignment asks that I return true indicating that python does see the word "uno" and returns true for the in function. Can someone tell me what I am doing wrong? thank you
Also when I do a print(f)
I do see that python returns the following:
print(f)
<open file '/Downloads/word.txt', mode 'r' at 0x207ed10>
Does that mean that python is reading the file correctly?