A File That Might Not Be There

Python for AIMedium+10 XP+10

A File That Might Not Be There

A step counter saves today's count in a small text file. On a brand-new phone, the file doesn't exist yet.

Write load_count(path) that opens the file at path, reads it, and returns the number inside as a whole number. The text may have spaces or a line break around the number.

If the file isn't there, return 0.

Catch only the missing-file error. The starter code already creates two files for you to test with: steps_monday.txt and steps_tuesday.txt.

Examples

path = "steps_monday.txt"
returns 8421
path = "steps_never.txt"
returns 0

Hints

Solve it to unlock the solution

Once your code passes every test, a reference solution shows up here so you can compare it with yours.

solution.py
CtrlEnterto run