Skip to main content
🔒 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 →
← CoursesCreative ChallengesModule 3 · 🕰️ Time-Travel Refactor (10)⏰ 2008 → 2026: open/read/close → pathlib.read_textpredict25 / 104
+125 XP
Task
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()

What will the program print? Write here:

💬 Discussion

Be the first to ask a question or share a tip.
Sign in to join the discussion. Reading is free.
Loading discussion…