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 trialChih-Wei Hsu
11,132 Pointswhen input number is .5
in the second example where the input number is .5, the resulting ratio variable should store the value 3 (from rounding 5 * .5), and the character at index 3 is 'i'. Does rounding work slightly differently in Python than the typical mathematical convention?
1 Answer
Amanda Harman
11,303 PointsIn Python, the round() function will round to the nearest integer. However, if the parameter is halfway between two integers, it rounds it to the nearest even number. So round(2.5) would output 2, while round(3.5) would output 4.