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 trialShane Smith
Python Development Techdegree Student 2,550 PointsBeginner challenge help!
I know that in line 4 i cant call the function i defined without passing it a parameter but I am unsure of how to proceed?
def hello_student(name):
return "Hello "+name
hello_student():
hello = return
1 Answer
rydavim
18,814 PointsAlright - so the return
statement you wrote while defining the hello_student
function is what you'll be using to "generate" the value of your new hello
variable.
def hello_student(name): # from task 1
return "Hello " + name
hello_student(): # no colon for function calls
hello = return # the return statement is part of the function
Instead of thinking of it like writing a function, you're using the function you already wrote to save the result to a new hello
variable. hello_student(rydavim)
would return the value "Hello rydavim", but that isn't being saved anywhere unless you assign it to a variable.
# create a variable to save the return value of a function
def exampleFunction(item):
return "Your item is: " + item
exampleVariable = exampleFunction(blueberries)
# exampleVariable is now set as "Your item is: blueberries"
Hopefully that gets you going, but let me know if you've still got questions. Keep it up!