Popcorn Hack 1: Extract the Hidden Message

Only indexing and slicing. "SIGNAL" starts at index 2 and is 6 characters long, so the slice is [2:8] (the stop index is excluded).

Code Runner Challenge

Popcorn Hack 1 - Extract the hidden message using indexing and slicing

View IPYNB Source
# CODE_RUNNER: Popcorn Hack 1 - Extract the hidden message using indexing and slicing

transmission = "xxSIGNALxxxCONFIRMEDxx77xxDELTA"

# TODO 1: "SIGNAL" starts at index 2 and is 6 characters long -> [2:8]
word_1 = transmission[2:8]
print("Word 1:", word_1)

# TODO 2: "CONFIRMED" starts right after "SIGNALxxx" (index 11) and is 9 characters -> [11:20]
word_2 = transmission[11:20]
print("Word 2:", word_2)

# TODO 3: NEGATIVE slicing, "DELTA" is the last 5 characters
word_3 = transmission[-5:]
print("Word 3:", word_3)

# TODO 4: len() counts every character in the FULL transmission
print("Total length:", len(transmission))

# TODO 5: step of 2 prints every other character
# Only scraps of the message survive: the step skips letters, so the words are broken up
print("Every other character:", transmission[::2])
Lines: 1 Characters: 0
Output
Click "Run" in code control panel to see output ...

Answer to TODO 5’s question: Not really. Stepping by 2 keeps only every other letter, so the words are chopped up (SGA, OFRE, DLA). Only a full slice with the right start and stop reveals them.

Popcorn Hack 2: Scrub and Search a Noisy Transmission

Only string methods. Every method returns a new string, so each result is saved in a variable.

Code Runner Challenge

Popcorn Hack 2 - Clean and search a noisy transmission using string methods

View IPYNB Source
# CODE_RUNNER: Popcorn Hack 2 - Clean and search a noisy transmission using string methods

noisy = "   ...AGENT>>>Falcon---reports: the PACKAGE has ARRIVED!!!   "

# TODO 1: .strip() removes the leading/trailing whitespace
trimmed = noisy.strip()
print("Trimmed:", repr(trimmed))

# TODO 2: .replace() once for each noise character (removing it by swapping in an empty string)
cleaned = trimmed.replace(">", "").replace("-", "").replace("!", "")
print("Cleaned:", cleaned)

# TODO 3: .lower() makes an all-lowercase COPY
lowered = cleaned.lower()
print("Lowered:", lowered)

# TODO 4: the `in` operator is a case-insensitive search once we search the lowercase copy
has_arrived = "arrived" in lowered
print("Contains 'arrived':", has_arrived)

# TODO 5: .split() with no arguments breaks on any whitespace
words = cleaned.split()
print("Word count:", len(words))
Lines: 1 Characters: 0
Output
Click "Run" in code control panel to see output ...

Note: Removing > and - (instead of replacing them with spaces) glues AGENT and Falcon together, so the word count is 5, exactly as the TODO asks.

Popcorn Hack 3: Build a Decoded Report

Concatenation with + and str(), then f-strings and .join().

Code Runner Challenge

Popcorn Hack 3 - Build a decoded report using concatenation and formatting

View IPYNB Source
# CODE_RUNNER: Popcorn Hack 3 - Build a decoded report using concatenation and formatting

agent_name = "Falcon"
target_word = "MIDNIGHT"
confidence = 87          # a percentage, stored as an int
fragments = ["ALPHA", "SEVEN", "DELTA"]

# TODO 1: + concatenation
headline = "Agent " + agent_name + " intercepted: " + target_word
print(headline)

# TODO 2: str() converts the int so + works
confidence_line = "Confidence: " + str(confidence) + "%"
print(confidence_line)

# TODO 3: the SAME line as an f-string
confidence_line_fstring = f"Confidence: {confidence}%"
print(confidence_line_fstring)

# TODO 4: "-".join() turns the list into ONE string
joined_fragments = "-".join(fragments)
print("Joined fragments:", joined_fragments)

# TODO 5: one final f-string report
final_report = f"REPORT: {headline} | {confidence_line} | Fragments: {joined_fragments}"
print(final_report)
Lines: 1 Characters: 0
Output
Click "Run" in code control panel to see output ...

Homework Hack: Crack the Final Transmission

A CSV row that needs slicing, methods, and formatting to fully decode: strip and split, index, slice-check the year, clean and search, then rebuild it as a Markdown table row and a JSON-style line.

Code Runner Challenge

Homework - Crack the Final Transmission using slicing, methods, and formatting

View IPYNB Source
# CODE_RUNNER: Homework - Crack the Final Transmission using slicing, methods, and formatting

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

# TODO 1: .strip() the outer whitespace, then .split(",") into fields (exactly 4, no empty strings)
segments = raw_transmission.strip().split(",")
print("Segments:", segments)

# TODO 2: indexing on the list pulls out each field
date = segments[0]
agent = segments[1]
message_code = segments[2]
confidence_str = segments[3]
print("Date:", date, "| Agent:", agent, "| Message code:", message_code, "| Confidence:", confidence_str)

# TODO 3: SLICING (no method) the first 4 characters and compare to the year
year_check = date[:4] == "2026"
print("Year check:", year_check)

# TODO 4: .replace() turns the dashes into spaces
message = message_code.replace("-", " ")
print("Message:", message)

# TODO 5: .lower() plus `in` gives a case-insensitive search
found_dawn = "dawn" in message.lower()
print("Found 'dawn':", found_dawn)

# TODO 6: f-string with | separators makes a Markdown table row
markdown_row = f"| {date} | {agent} | {message} | {confidence_str}% |"
print("Markdown row:", markdown_row)

# TODO 7: f-string JSON line (braces come from variables, str(...).lower() makes true/false)
open_brace = "{"
close_brace = "}"
json_line = f'{open_brace}"date": "{date}", "agent": "{agent}", "message": "{message}", "confidence": {confidence_str}, "contains_dawn": {str(found_dawn).lower()}{close_brace}'
print("JSON line:", json_line)
Lines: 1 Characters: 0
Output
Click "Run" in code control panel to see output ...

Checklist: # CODE_RUNNER: on line 1, one slice that uses no method (date[:4]), four string methods (.strip(), .split(), .replace(), .lower()), a Markdown row and a JSON line built from the decoded fields, no input(), no import.