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

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
217,531 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.