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 Functions and Looping Returning Values

fahad lashari
fahad lashari
6,141 Points

My solution

I tried to just use what's been learnt so far and scaled it down to make it as simple as possible but feel like I made it more complicated in terms of how I am calling the function. If you guys have any tips on how I can make it simpler; Please feel free to let me know :)

Will now watch the video and see Craig's approach.

def split_check(total_bill, total_people):
  amount_due_each = total_bill / total_people
  return amount_due_each

print("Result: £{0:.2f}".format(split_check(int(input("What is the total amount?\n£")), int(input("How many people attended?\n")))))

Kind regards

1 Answer

Steven Parker
Steven Parker
210,424 Points

Since you only return the computed value, you can skip the creation of the variable:

def split_check(total_bill, total_people):
  return total_bill / total_people
fahad lashari
fahad lashari
6,141 Points

Thanks! didn't think of this