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

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,438 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.