Menu

Sign in to track your progress and unlock all features.

Theme style

Log in

Problem No 6

Concatenate Strings

Easy

10 minute session

Summary

Learn how to join strings by concatenation and return the combined result.

Problem statement

Implement join_names(first, last) that returns a single string combining first and last name separated by a single space. The function should not modify the inputs aside from joining them with a space.

Task

Write a function that combines two name parts into a single string with a space between them.

Examples

Example - joining two names

Input

join_names('Ada', 'Lovelace')

Output

Ada Lovelace

Explanation

Join 'Ada' and 'Lovelace' with a space between them.

Input format

Two string parameters: first and last.

Output format

A single string that is the concatenation of first, a space, then last.

Constraints

Do not add extra spaces beyond one between the names. Handle empty strings by still returning the single space when appropriate (e.g., '' + 'Smith' -> ' Smith').

Samples

Sample input 0

join_names('John', 'Doe')

Sample output 0

John Doe

Explanation 0

Returns the two names joined by one space.

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.

02:25 AM

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