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 trialoliverchou
20,886 PointsCan't get it right~
What's wrong with my code, and is the round() method necessary in this challenge? If so, how to use it?
# The first half of the string, rounded with round(), should be lowercased.
# The second half should be uppercased.
# E.g. "Treehouse" should come back as "treeHOUSE"
def sillycase(s):
middle = len(s)/2 + 1
return s[:middle].lower() + s[middle:].upper()
1 Answer
Henrik Christensen
Python Web Development Techdegree Student 38,322 PointsThis should do it:
def sillycase(string):
midpoint = round(len(string)/2)
return string[:midpoint].lower() + string[midpoint:].upper()
NOTE There was a lot of posts asking this question in the forum and took me like 2 secs to find the answer - the way of searching in the forum could save you some time and maybe some frustations :-)
oliverchou
20,886 PointsThank you ~ I'll try it next time! :)
Cheo R
37,150 PointsCheo R
37,150 PointsI redid it using round() and I got the output you are expected to have.