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 Escobar
Daniel Escobar
2,580 Points

Why can I not use the following code? it does what it is being asked.

sillycase.py
def sillycase(s_line):
    new_case = s_line[::]
    case_2 = new_case[0:4].lower()
    case_3 = new_case[4:].upper()
    print(case_2 + case_3)

sillycase("treehouse")

1 Answer

Steven Parker
Steven Parker
229,732 Points

You're getting close, here's a few hints:

  • you only need to define the function, you won't need to call it yourself
  • the function should work with strings of any length
  • the instructions about "indexes should be integers" is a clue about computing sizes
  • it's not necessary to make a copy of the argument, you can use it directly