Menu

Sign in to track your progress and unlock all features.

Theme style

Log in
01. Define a VariableE02. Store a StringE03. Convert Data TypesE

Problem No 2

Store a String

Easy

8 minute session

Summary

Practice creating and returning strings made from input values.

Problem statement

Implement the function greet(name). Inside the function, create a variable greeting that holds the text "Hello, " followed by the provided name. Return the greeting string. This teaches simple string storage and concatenation.

Task

Build a greeting string by storing a concatenated value in a variable and returning it.

Examples

Greet a person

Input

greet('Alice')

Output

Hello, Alice

Explanation

Concatenate 'Hello, ' and the name 'Alice', store it in greeting, and return it.

Input format

A single string argument name passed to greet(name).

Output format

Return a string with the greeting 'Hello, ' + name.

Constraints

Do not print. The function should return exactly the greeting string. Handle empty names by still returning 'Hello, '.

Samples

Sample input 0

greet('Bob')

Sample output 0

Hello, Bob

Explanation 0

Returns the greeting built from the provided name.

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:05 PM

Free preview includes 1 Teach Theory response and 1 AI hint on each of the first 3 lessons in this module.