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.
When you entered .75, it should round off to the 4th out of 5 letters. But yours showed the 5th letter because user_string obviously shows the 5th letter. Which is not what you want, is it? The index should be user_string[ratio-1]?
Chris FreemanTreehouse Moderator 68,064 Points
Be careful not to confuse the index value with the count position. The value indeed rounds off to 4, but in the code it rounds off to index 4, not the 4th character. Index 4 is the 5th character.
Inspecting the code, the string offset is given by:
user_string = "Magic" ratio = round(len(user_string)*our_num) ratio = round(5 * 0.75) ratio = round(3.75) ratio = 4
The element at index 4,
user_string, is "c".
Sorry if I'm remembering wrong, but didn't you want to pick out the letter that was closest to 75% "into" the word? Which would be the "i", no? That's why I was thinking you wanted the 4th character, or index 3 (ratio-1)