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

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.