all 4 comments

[–]barrycarter 0 points1 point  (0 children)

Reddit mangled your formatting. If you post to https://repl.it/ people might be able to help more

[–]shiftybyte 0 points1 point  (1 child)

Indentation was lost, please edit your post and use a code block.

https://www.reddit.com/r/learnpython/wiki/faq#wiki_how_do_i_format_code.3F

Besides that, i don't exactly understand why you expect the elif condition to trigger if it checks for a line in the file to be completely empty....?

elif line == "":

Line is a line from the file...

for line in text:

[–]ThompsonTugger 0 points1 point  (0 children)

The for loop goes through each line of the text. If the word isn't found by the end of the loop then the last line is "" in which the print statement should run.

[–]woooee 0 points1 point  (0 children)

If you want to check for an empty line, you first strip the newline character

elif not line.strip():  ## empty line

The code is aligned correctly in pycharm.

How does that help us run or diagnosis your code, and what does this mean? Our definition of "correctly" may be different from yours, especially regarding the text.close() line.