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 Python Basics (Retired) Putting the "Fun" Back in "Function" Functions

argument

What is the simple definition of a argument and why is it used.

1 Answer

An argument is simply a value provided to a function when you call it: x = foo( 3 ) # 3 is the argument for foo y = bar( 4, "str" ) # 4 and "str" are the two arguments for bar

Arguments are usually contrasted with parameters, which are names used to specify what arguments a function will need when it is called. When a function is called, each parameter is assigned one of the argument values.

foo has two named parameters, x and y

def foo ( x, y ): return x + y

z = foo( 3, 6 )

foo is given two arguments, 3 and 6. The first argument is assigned to the first parameter, x. The second argument is assigned to the second parameter, y.