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.
Lukas Johmann911 Points
I got the code to calculate Service Charge without making a function
Other than good practice for clean code, and readability, I don't see any purposes right now for making an extra function for service charge. I was able to add the Service charge into the code with a lot less work and seemingly the same end result.
amount_due = (TICKET_PRICE * num_tickets) + SERVICE_CHARGE
Can someone explain to me what this calculate_price function can achieve or allow us to do with our code?
I would appreciate your responses :) Thanks in advance
Like you said, defining this function isn't necessary. Craig basically mentions this, as well. Usually the reason for creating functions is to avoid repeating code, and in this video that's not case.
All in all, for the scope of the video, it isn't needed, but the only point is for refactoring. Cleaner code goes a very long way when projects get larger, so sometimes its best to think ahead in the beginning.