Code Runner Challenge

Homework

View IPYNB Source
# CODE_RUNNER: Homework

raw_transmission = "  2026-09-15,GHOST,THE-EAGLE-LANDS-AT-DAWN,87  "

segments = raw_transmission.strip().split(",")
print("Segments: ", segments)

date = segments[0]
agent = segments[1]
message_code = segments[2]
confidence_str = segments[3]
print("Date: " + date)
print("Agent: " + agent) 
print("Message code: " + message_code)
print("Confidence: " + confidence_str)

# 3. Slice the date to confirm the year (slicing, not a string method)
year_check = date[0:4] == "2026"
print("Year check:", year_check)

# 4. Turn the dashes into spaces, then search without caring about case
message = message_code.replace("-", " ")
found_dawn = "dawn" in message.lower()
print("Found 'dawn':", found_dawn)

# 5. Rebuild the decoded fields as a Markdown table row
markdown_row = f"| {date} | {agent} | {message} | {confidence_str}% |"
print("Markdown row:")
print(markdown_row)

# 6. Rebuild the same data as a JSON-style line. The object braces are added
#    as plain strings, then the fields come from f-strings.
json_line = (
    "{" +
    f'"date": "{date}", "agent": "{agent}", "message": "{message}", ' +
    f'"confidence": {confidence_str}, "contains_dawn": {str(found_dawn).lower()}' +
    "}"
)
print("JSON line:")
print(json_line)
Lines: 1 Characters: 0
Output
Click "Run" in code control panel to see output ...