Menu

Sign in to track your progress and unlock all features.

Theme style

Log in

Problem No 9

Use Escape Characters

Easy

6 minute session

Summary

Create strings that include newlines, tabs, and quotes using escape sequences.

Problem statement

Write a function format_poem(title, line) that returns a two-line string where the first line is the title, and the second line is the provided line preceded by a single tab character. The exact returned string should be: {title}\n\t{line} Do not print; return the string. Preserve any characters in title and line (including quotes and backslashes).

Task

Learn and practice escape sequences like \n (newline) and \t (tab) to format multi-line strings.

Examples

Simple poem

Input

format_poem('Ode', 'To Joy')

Output

Ode\n\tTo Joy

Explanation

The function returns a string with a newline and a tab before the line.

Input format

Two strings: title and line.

Output format

A single string containing one newline and a tab as described.

Constraints

Return a string. Do not add extra spaces or lines. Preserve characters in inputs.

Samples

Sample input 0

format_poem('Title', '')

Sample output 0

Title\n\t

Explanation 0

An empty second line still gets the tab after the newline.

Code editor
Loading editor…

AI assistant

Ask me anything!

Need help? I can explain the core idea behind this problem, review your current code, and give targeted hints. Use “Teach Theory” for the concept, “Get AI hint” for a quick scaffold nudge, or ask a specific question below.

Chat history is temporary and will not be saved.

04:59 AM

Free preview includes 1 Teach Theory response and 1 AI hint per unlocked preview lesson.