Menu

Sign in to track your progress and unlock all features.

Theme style

Log in

Full lesson preview

Use Escape Characters

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

Python practice6 minVariables & Data TypesBeginnerLast updated December 29, 2025

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

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 1

Input

format_poem('Title', '')

Output

Title\n\t

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