LearnPy Hub
← Context Managers problems
Medium

Safe File Stats

Write the input lines (until END) to data.txt inside a with block. In another with block, read it and print the number of lines and the number of words.

Input

Lines, then END.

Output

Two numbers.

Sample 1

Input
hello world
hi
END
Output
2 3

Sample 2

Input
one
END
Output
1 1
solution.py
Output appears here
Safe File Stats · Python practice problem · LearnPy Hub