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

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.