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!
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
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.