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! While you're at it, check out some resources Treehouse students have shared here.

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

Son-Hai Nguyen
Son-Hai Nguyen
2,481 Points

My way of approaching

Hi, so below is my way to approach this "check_please" app. Pls take a look, and feel free to tell me what do you think

My method

import math

def splitCheck(total, numberOfPeople): r = math.ceil (total/numberOfPeople) print ("So each one will have to pay ${}".format (r))

totalDue = float (input ("How much for the meal? ")) numberOfPeople = int (input ("How many people are there? "))

splitCheck (totalDue, numberOfPeople)

And by the way, can anyone spot the difference between the "print" and "return" functions? Thanks a lot!!!

1 Answer

I think it is better for the "splitCheck" function to return a value rather than to print a statement.

That way it is easier to use the returned value for other purposes if needed.