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 trial
Cedric Lefrancois
1,776 PointsWhen was "wishes" assigned its value?
Hi everyone,
I'm still pretty new to this and I don't understand how or when "wishes" was defined or assigned a value..
Thank you,
4 Answers
Jennifer Nordell
Treehouse TeacherHi there, Cedric Lefrancois! It was assigned a value the moment we called the function. The wishes is a parameter in the function definition. A parameter is used to "catch" an argument at the moment we call/invoke/execute the function (however you prefer to say it).
For instance:
def say_hi(name):
print(f"Hi there, {name}")
Right now, name has no value at all. It's an empty variable just waiting for something to be assigned to it.
However, if I were to do this:
say_hi("Cedric")
That calls the function and sends it the string "Cedric". Now name does have a value and it is "Cedric".
The function shown here starts with:
def display_wishes(display_name, wishes):
At this point neither display_name nor wishes have any value whatsoever. But when I do this:
display_wishes("Video Games", video_games)
Then display_name gets a value of the string "Video Games" and wishes gets whatever is stored in video_games.
Hope this helps!
Marisa Blanco
5,358 Points--- --- I actually had the same question and this broken down in a way that is very easy to understand for those of us who are starting from 0. Thank you for taking the time!
Cedric Lefrancois
1,776 PointsThis is great! Thanks for taking the time to break this down and post examples as well. Super cool!
Patrick Robinson
623 PointsThank You so much! You made this so much simpler and clear!
justlevy
6,326 Pointsjustlevy
6,326 PointsVery helpful. Thanks!