Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Python Basics All Together Now Cleaner Code Through Refactoring

grantcenter
grantcenter
8,421 Points

Question on calling the service charge function

I had almost everything right in my code except i was originally calling the function like:

amount_due = calculate_price

instead of:

amount_due = calculate_price(number_of_tickets)

I guess my question is why do you have to include the (number_of_tickets) part when calling the function? Is that actually a part of the function name? Just a little confused because earlier it felt like that was just a placeholder

1 Answer

Steven Parker
Steven Parker
210,468 Points

The "number_of_tickets" is what is known as an argument to the function. The function uses this value to compute the amount. It is the value of the argument that is assigned to the parameter, which is the placeholder that was used in the function definition.

And FYI: even when a function doesn't need any arguments, you still must put parentheses after the name when you call it.