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 trialRafael Quintero
9,935 Pointssillycase function
Not sure what I'm doing wrong
def sillycase(string):
length_first_half = int(len(string)/2)
first_half = string[:length_first_half]
second_half = string[len(first_half):]
upper_second_half = second_half.upper()
return first_half + upper_second_half
1 Answer
Ari Misha
19,323 PointsHiya Rafael! First off, you're not rounding your halves into appropriate integer. Comes "Integer division" to the rescue. Integer Division not only divides two numbers for ya , it converts 'em in ints and also round 'em to nearest int value.
Second off, on line 3, you've an error. And Third off, clean up your code a bit.
Here is how your code should look like:
def sillycase(string):
length_half = len(string) // 2
return string[:length_half].lower() + string[length_half:].upper()