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

Python

HELP! CONFUSED WITH PARAMETERS In python

I am a little bit confused with how parameters work. and what they do

1 Answer

Hi Muhammad,

Parameters were at first confusing for me as well, but they're actually pretty simple at least at a high level.

I look at them as placeholders in a function, for data you plan to pass to it when the function is called. For example, in this simple function:

def simple(x,y):
    print (x, y)

...x and y are placeholders for values you'll pass in the main body of your code.

So if we ran:

print (simple("purple", 55))

The program would print:

purple 55

As you can see, when the function is called, x and y are replaced with the values we pass in the call.

Does that make sense?

Hi akoniti,

Just changed this from a comment to answer so it can be voted on. Thanks for responding!