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

281 Points

i tryed to add input questions for the 2 varibles but it didnt work ..

def split_check(total,num_of_ppl): cost_per_person = total / num_of_ppl return cost_per_person

total = input("what was the total of the check?") num_of_ppl = input("how many ppl are contributing?")

amount_due = split_check(total,num_of_ppl) print ("each person owes $()".format(amount_due))

just curious why this doesnt work... thank you

1 Answer

input returns a string so these values will have to be converted to numbers prior to passing them to the split_check function where division is performed. You see this conversion in the video with the float and int methods.

total = float(input("what was the total of the check?"))


num_of_ppl = int(input("how many ppl are contributing?"))
281 Points

Face Palm I remember now than you