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

Code works but the result is wrong. Running this code i use 5 for the number of ppl and 555. it returns 1 instead of 111

import math

def spli_check(total, number_of_ppl): cost_per_pers = math.ceil(total / number_of_ppl) return cost_per_pers

total = float(input("Please Input number of ppl ")) number_of_ppl = int(input("Please Input cost ")) amt_due = spli_check(total, number_of_ppl )

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

nvm... Figured it out. I assigned my variables incorrectly. Very messy code. will do better.

1 Answer

Steven Tagawa
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Steven Tagawa
Python Development Techdegree Graduate 14,238 Points

You have your inputs switched around. When you ask for the number of people, you're assigning it to the cost variable, and when you ask for the total cost, you're assigning it to the number of people variable.