Problem with a Python script to count number of lines containing a word
I have the following text :
Paris Berlin Berlin
I wish to count the number of lines containing London (3 lines)
I run the following workflow
which gives me the answer "The word London occurs in 0 lines" (but the highlighting on the contrary is correct)
The explanation is most certainly evident, but I cannot find it…
Where did I go wrong ?
Thanks in advance
When you iterate over a string, each iteration is one character of the string, not one line.
for line in wftext.splitlines():instead of
for line in wftext:, and it should work as expected.
Thank you very much for your answer and, may I add, thank you very much for this indispensable app (together with Pythonista, of course…)