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

Daniel Sayre
Daniel Sayre
884 Points

My sillycase works in python but not in workspace?

I put this into the python 3.6.4 and it worked fine in the shell but in workspaces I get 'Bummer! Try again!' I split up a lot of lines so each line had just 1 or 2 operations but I don't see where my error is. Please assist.

sillycase.py
def sillycase(halfsies):
    uppers=halfsies [(int(len(halfsies)/2)): ]
    lowers=halfsies[ :(int(len(halfsies)/2))]
    uppers=[letter.upper() for letter in uppers]
    lowers=[letter.lower() for letter in lowers]
    both_halfs=(lowers + uppers)
    both_halfs=["".join((both_halfs)[0:-1])]
        return (both_halfs)

2 Answers

Steven Parker
Steven Parker
229,759 Points

I see a few issues:

  • the slice applied to the result of the "join" chops off the last letter
  • the join is wrapped in brackets which makes the result a single-item list instead of a string
  • the "return" statement is excessively indented

You could also make the function much more concise if you omitted the conversion to and from lists and worked directl with strings (the case conversion functions don't have to be applied to just one letter at a time). But that's not necessary to pass the challenge.

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,423 Points

You are close. The code returns ['treeHOUS']

  • remove the unnecessary slice on the argument to join
  • do not put the join inside of a list

Post back if you need more help. Good luck!!

Daniel Sayre
Daniel Sayre
884 Points

Thanks. I appreciate the assistance.