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 →
← CoursesPython FoundationsModule 8 · Modern Python and capstonelogging — handlers, levels, formatterspredict168 / 174
+75 XP
Task
📝 **Question:** Predict the output of the snippet below. 📋 Pick the right answer. 💡 **Hint:** Re-read the theory above if unsure.
Predict the output

Read the code carefully

import logging, io

buf = io.StringIO()
h = logging.StreamHandler(buf)
h.setFormatter(logging.Formatter("%(levelname)s:%(message)s"))

log = logging.getLogger("demo")
log.handlers.clear()
log.addHandler(h)
log.setLevel(logging.INFO)

log.debug("hidden")
log.info("hello")
print(buf.getvalue().strip())

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…