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 (Retired) Slices sillyCase

Srikanth Srinivas
Srikanth Srinivas
1,465 Points

Why isn't this script passing?

I accomplished what the prompt suggested i should. However, it will not let me pass the challenge, but results in a communication error.

silly.py
# The first half of the string, rounded with round(), should be lowercased.
# The second half should be uppercased.
# E.g. "Treehouse" should come back as "treeHOUSE"

def sillycase(strin):
  liste =[strin]

  lower = str(strin[:int(len(strin)/2)])
  upper = str(strin[int(len(strin)/2)::1])
  return lower.lower() + upper.upper()

2 Answers

if its a communication error contact support

Hi Srikanth

Even though your code returns the correct output, line 1 -> you are not actually converting the string into a proper list rather creating a string "Treehouse" at index 0.. your way of doing it returns ["Treehouse"] for liste but it should actually return ['T', 'r', 'e', 'e', 'h', 'o', 'u', 's', 'e'] when you convert to a list properly.

I did it this way and passed the challenge.

# The first half of the string, rounded with round(), should be lowercased.
# The second half should be uppercased.
# E.g. "Treehouse" should come back as "treeHOUSE"


def sillycase(mystring):
  mylist = list(mystring)
  firsthalf = mylist[0:round(len(mylist)/2)]
  secondhalf = mylist[round(len(mylist)/2): len(mylist)]
  return "".join(firsthalf).lower()+"".join(secondhalf).upper()