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
Jørgen Johansen
4,912 PointsHow is a python function valid and functioning on my Mac, but not in the Code Challenges on Treehouse?
I have this code written for the Python Collections class, where I'm supposed to make the first half of the text lowercase and the remainder uppercase. This works when I do it on my Mac locally, but the Treehouse Code Challenge won't accept my answer. What am I doing wrong?
https://www.dropbox.com/s/ph4hswncedbya70/Screenshot%202017-02-16%2023.03.18.png?dl=0
Here are a Dropbox-link to a comparison of my Mac and the Treehouse Code Challenge
1 Answer
Cole Wilson
7,413 PointsIn Python 2 math defaults to integer so 3 /2 would equal 1. In python 3, math defaults to float so 3/2 would equal 1.5.
http://sebastianraschka.com/Articles/2014_python_2_3_key_diff.html#integer-division
My bet is that your calculation of half only works when the length of the string is even.
Jørgen Johansen
4,912 PointsJørgen Johansen
4,912 PointsYou are absolutely right!
My Mac were running 2.7 and Treehouse 3.5. The fix for future referanse is like this: