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.
Ingrid Matthews1,465 Points
Why isn't "total" defined?
I was puzzled by this. In my workspace I did exactly what Craig did, leaving "total" undefined, and it worked, but then I changed "total" to "total_due" in those two places, and it ALSO worked. At 9:20 in the video, you can see that he's using "total_due" below, but at the top in the definition of split_check it's just "total." ??. Thanks for any clarification!
The function parameters can be named whichever way you want, so as long as you use the same name inside the function to refer to the argument that was passed it. Eg.
def print_a_number(number): print(number) print_a_number("foobar")
Please note that the above is a bad example, it's just to illustrate the point. Even though the function parameter is called number... I've passed in a string as an argument instead. With that said, you always want to be descriptive, and make your code read well.