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 trialAlexander Alcaraz
550 PointsWhat is an argument?
So I went over the video and have a decent understanding of a function. However, now it's asking me to multiply "Hi " with as many times as an argument 'count' is. I did a little digging on the net and it points back to index. So I figured, "Oh!, I know that" and I count from 0 - 4. Now I'm multiplying by 4 hoping that it'll work but it doesn't I feel like I'm missing something so simple. I mean the video didn't mention arguments I don't think...
def printer(count):
print("Hi ") * 4
printer()
3 Answers
Kurt Maurer
16,725 PointsHi Alexander,
There's an important distinction here when defining and using functions. When defining a function, the variables you pass into the parentheses are the parameters.
def printer(count): # count is a parameter
When you call the function, the variable you pass into the parentheses is called on argument.
printer(5) # 5 is an argument
They are sometimes used interchangeably, but they are technically not the same thing.
In your function, you need ('Hi ' * count)
to get your desired output. Right now, your definition has a parameter it doesn't use, and it will always print 'Hi ' 4 times (needs to be 5 times). I hope this helps!
Jon Wood
9,884 PointsThe count
is the parameter to the printer
method. You're probably getting an error that the printer
method takes only one argument while you're passing it none. Pass in an integer argument and modify the method to use the count
parameter, and you should be good to go!
BENJAMIN UWIMANA
Courses Plus Student 22,636 PointsKurt Maurer answered it very cleary. Nothing to add.
Kurt Maurer
16,725 PointsKurt Maurer
16,725 PointsFor more, see this Stack Overflow post:
http://stackoverflow.com/questions/156767/whats-the-difference-between-an-argument-and-a-parameter