Skip to content
dreamcode
dreamcode
← Map
Observation Logger
Section challenge · AdvancedPython
Reward: +60 XP
PROBLEM

Observation Logger

Write a decorator add_telemetry that wraps a function returning a string. The decorator should prepend '[Telemetry] ' to the returned string.

Also write a function test_decorator(val) that defines a local function decorated with @add_telemetry and returns the result of calling it with val.

Examples
test_decorator('sky is clear')
→ '[Telemetry] sky is clear'
test_decorator('storm incoming')
→ '[Telemetry] storm incoming'
solution.py
PYTHON
Saved as you type

Tests

0 of 3 passing
  • •
    clear sky → telemetry prepended
    test_decorator('sky is clear')
    expected '[Telemetry] sky is clear'
  • •
    storm alert → telemetry prepended
    test_decorator('storm incoming')
    expected '[Telemetry] storm incoming'
  • •
    empty string → just the tag
    test_decorator('')
    expected '[Telemetry] '
On the line
+60 XP
Pass all 3 tests to claim it.