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

Question about variable names in functions

In the check please example how does Python know to use the user input from total_due as the total???? Shouldn't the variable be called total?

import math

def split_check(total, number_of_people): return math.ceil(total/number_of_people)

total_due = float(input("What is the total? ")) number_of_people = int(input("How many people? "))

amount_due = split_check(total_due, number_of_people)

print("Each person owes ${}".format(amount_due))

2 Answers

total_due is passed into split_check() as an argument here:

amount_due = split_check(total_due, number_of_people)

The parameter total of split_check could be named anything (following naming conventions) however the code within the function would have to be updated with the new name. For example:

def split_check(x, y):
  return math.ceil(x/y)

would return the same result

ok I see. The arguments name is unimportant. it's where you place the arguments when calling the function that matters

Darcie Kutryk
Darcie Kutryk
2,129 Points

Thanks Catherine, I had the same question.