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

Python Python Basics Functions and Looping Returning Values

fahad lashari
fahad lashari
7,693 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
227,114 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
7,693 Points

Thanks! didn't think of this