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

Emilio Andere
Emilio Andere
495 Points

Im really confused

can someone help me with this please

sillycase.py
def sillycase(string):
    string[:5].lowercased
    string[5:].uppercase

sillycase(Treehouse)

2 Answers

Steven Parker
Steven Parker
231,275 Points

Here's a few hints:

  • you won't know how long the string will be, so you can't used fixed values in the slice
  • the names of the functions for changing case are ".lower()" and ".upper()"
  • you'll need to combine the two new parts together
  • you'll need to "return" the combined result
  • you only need to define the function, you don't need to call it yourself
Emilio Andere
Emilio Andere
495 Points

how do I combine 2 parts together

Steven Parker
Steven Parker
231,275 Points

You can perform string concatenation with the "+" operator.

Ryan Cross
Ryan Cross
5,742 Points

this is the challenge that was half upper half lower? heres a hint. you wont know how long it is but you can still cut it in half. if youre still stuck I'll help you.

Emilio Andere
Emilio Andere
495 Points

im still stuck, lol

Ryan Cross
Ryan Cross
5,742 Points

Emilio! In your code you set the string halves with a slice, You have assumed the length of that string. You might not have the strings length right if you guessed. Better to get the length with len() as len(your_string) then cut it in half as len(your_string)/2...this integer will help you indexing the halves of your_string.

another problem is the way you're trying to change cases? the method is lower() or upper() as in half_a_string.lower()

i hope this helps you. If you're struggling with a method like .lower(), upper() or len() go to the python docs they're helpful once you get onto them. Good luck.