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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Nick B.](https://secure.gravatar.com/avatar/68ecb351ac2d1d7a39ae2e38c02aee08?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Nick B.
Full Stack JavaScript Techdegree Graduate 31,101 PointsCan someone please explain the float() in Python for me please?
import math
def split_check(total, number_of_people): return math.ceil(total / number_of_people)
try:
total_due = float(input("What is the total? "))
number_of_people = int(input("How many people? "))
except ValueError:
print("Oh no! That's not a valid value. Try again...")
except ZeroDivisionError:
#
else:
amount_due = split_check(total_due, number_of_people)
print("Each person owes ${}".format(amount_due))
What does float do here in the total_due variable?
2 Answers
![Jose Borges](https://uploads.teamtreehouse.com/production/profile-photos/10717221/micro_tumblr_pcsi17aZKr1qla6e4o1_1280.jpg)
Jose Borges
Python Web Development Techdegree Student 2,953 PointsIt's converting the input of "What is the total?" which would be a string type into a floating number type, a decimal, which is how money would be represented. Similarly the next variable (number_of_people) converts an input (string) into an integer (since people wouldn't be represented as decimals). This allows them to be used in the arithmetic function split_check().
![Nick B.](https://secure.gravatar.com/avatar/68ecb351ac2d1d7a39ae2e38c02aee08?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Nick B.
Full Stack JavaScript Techdegree Graduate 31,101 PointsGot It! Thanks Jose.