Lesson guide
What this Python exercise practices
Store a String is a beginner practice lesson that focuses on strings, formatting, traversal. It is designed to be solved in about 8 minutes with examples, starter code, and test feedback.
Prerequisites
- Python variables
- String values
- Basic indexing
Difficulty and time
- Level
- Beginner
- Estimated time
- 8 minutes
Related public exercises
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.
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.
Free preview includes 1 Teach Theory response and 1 AI hint per unlocked preview lesson.