My Journal Entry Project

With help from the forums (mostly @mtf) I have completed my first independent project. This project allows you to write a journal entry and also search for a word in the entries. I have only finished 1/5 of the Computer Science Career Path so I am excited to learn more and share more. Let me know if there is anything that could make this program better! Here is the link: Enjoy!


Just noticed that the file close is in the else clause of the if statement. It should be outside of the if but inside the for loop.

Ok, I think I fixed it…

Line 44 still looks like it has too much indentation.

You are correct. Dang, you are good! Ok, I THINK its fixed now… :eyes:

Seems it is not…


should be,


:neutral_face: omg lemme try this again

So not like this: image
But like this: image

wait that doesnt work

Indent should be in line with the if (4 space indent) so that it is still inside the for loop, but not in the if statement.

I not going to say its fixed but you may check it if you want

Just give it 2 more spaces so it lines up with IF.

def search():
  word = input("What is the word you are looking for? ")
  file_names = []
  for x in os.listdir():
      if x.endswith(".txt"):
  for files in file_names:
    file_s = open(files, "r")
    read_file =
    if word in read_file: 
      print("The word", word, "was found in", files)
      print("The word", word , "could not be found")

This IF?

Yes. See my post above.


  for name in file_names:
    file = open(name, "r")

If something is singular, then it should not be pluralized. The above gives the two variable names a distinct difference, but both are singular.

Ok thank you! I will make that change. I cant believe it took me that long to fix an indent. You will be correcting me forever lol

1 Like

will the file = open(name, “r”) work though? Just because of the file function

file is neither a keyword nor a built-in of Python so it should work as expected.

oh, I did not know that. thanks

1 Like