← Back to Files
Question 419
Lines With The Word
Lines With The Word
Four fixed lines are written to poem.txt and a search word is read from input. Inside the read-back loop (the newline is already removed from line), print the line when the word appears in it (use the in test on strings) and add 1 to count; the final print, already written, reports how many lines contained the word. Input: one line, the word, no prompt.
Expected Output:
the sun is warm a warm cup of tea 2 line(s) contain warm
= newline. The output ends with a newline — print one after the last line.
Hints3 available
Sign in to use hintsTopics:
Files
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Ctrl+Space to expand shortcuts (pr, inp, def)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.