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

Maba Bah
Maba Bah
2,744 Points

Why the coercion on total due?

Just wondering why the total_due is coerced into a float. I get for number_of_people there can't be 3.5 people thus it's coerced into an integer but why for total_due? Is it because there's a chance the number might be a float?

1 Answer

Steven Parker
Steven Parker
228,978 Points

I would say the string is converted into a number. "Coerced" would typically describe the implicit process that occurs when you perform an operation on different types.

And the value can be expected to represent dollars and cents, so a float is necessary to convert and store it correctly.