Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialAbigail Solomon
Data Analysis Techdegree Student 4,203 PointsStumped on how to return the value for this function. It doesn't seem like I'm allowed to use formatted strings.
So I tried a bunch of different approaches for this challenge and none of them seem to work. This is a little different from the example functions we're doing in the videos because it involves strings instead of integers. I tried using formatted strings to return a printed statement of the string "Hello" with the name written in the parameter, but that only results in an error. I also tried to assign a variable to the combined string of Hello and the student name and that also leads to the same error. This exercise doesn't seem to like when I use the + operator to join "Hello" and the name variable either.
Any help? I thought this was going to be more straight forward than it is.
def hello_student(name):
return Hello
1 Answer
Rohald van Merode
Treehouse StaffHi Abigail Solomon 👋
In the snippet you shared you're trying to return a variable with the name Hello
instead of a string "Hello"
. You'll also want to make sure to add the name
to the returned value.
You can either do this by string concatenation like this:
"Hello " + name
Or use a formatted string:
f"Hello {name}"
Hope this helps! 😄
Abigail Solomon
Data Analysis Techdegree Student 4,203 PointsAbigail Solomon
Data Analysis Techdegree Student 4,203 PointsSolved this one. It turns out I was overthinking and just had to put "Hello " + name after return on the second line. The answer is this: def hello_student(name): return "Hello " + name