🔒 Preview mode. The first 15 Foundations lessons are free; this one is Pro. Start a 7-day trial to unlock the editor, AI hints and the rest of the curriculum. Card required, cancel any time in Dashboard.Start 7-day trial →
Predict what the modernized pathlib version prints. `path.write_text` stores the string, `path.read_text` retrieves it, `len` is 15 for 'Hello from 1998'.
Predict the output
Read the code carefully
from pathlib import Path
path = Path("greeting.txt")
path.write_text("Hello from 1998")
text = path.read_text()
print(text)
print("length:", len(text))
path.unlink()