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

Python Python Collections (2016, retired 2019) Slices sillyCase

Gosh, I need help with this !

I've trouble converting first half of the integer to lowercase while the other, uppercase

sillycase.py
def sillycase(string1):
    final_string = list(string1)

    for letters in final_string:
        final_string[::]//2 ==

2 Answers

Steven Parker
Steven Parker
230,037 Points

Here's a suggested approach:

  • first determine what half the length is
  • then use that with slices to get a separate first half and last half
  • then you can apply the appropriate case conversions to each
  • finally re-assemble the halves and return that resut

You could optionally combine some of the steps to reduce to number of code lines.

def sillycase(string): half=len(string)//2 first_half=string[:half].lower() last_half=string[half:].upper() return first_half + last_half

Steven Parker
Steven Parker
230,037 Points

:warning: Explicit answers without any explanation are strongly discouraged by Treehouse and may be subject to redaction by staff or moderators.

Also, when posting code (with explanations), always use Markdown formatting.