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

Dan Glassman
Dan Glassman
3,529 Points

Getting error "Couldn't find 'sillycase' "

I think my logic and syntax are good. For some reason the program is not finding my function. Any help is appreciated.

def sillycase(o): c[:] = o h = len(c)//2 f = "".join(c[:h]) s = "".join(c[h:]) m = f.lower() + s.upper() return modified

sillycase.py
def sillycase(o):
    c[:] = o
    h = len(c)//2
    f = "".join(c[:h])
    s = "".join(c[h:])
    m = f.lower() + s.upper()
    return modified
Anthony Box
Anthony Box
7,435 Points

it looks like you are copying string o into a un-initialized array c. why copy c to o, it's making program a little bulkier. better

def sillycase(o):
    h = len(o)//2
    m =o[:h].lower() +o[h:].upper()
    .......

also did you mean to for modified to be m?

1 Answer

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,457 Points

You have two typos:

  • c[:] = o should be c = o[:]
  • "modified" is not defined, should be return m

Additionally, it is better programming style to use full variable names as a single character doesn't sufficiently provide meaning to what the variable holds.