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

Vincent C
Vincent C
1,376 Points

Silly case challenge not passing, but working in workspace

Hi,

Just wrote this and it works in Workspace as per instructions, however, it's not passing the challenge. I understand it can be finicky but why do you think that is and how should the code have been improved?

Thanks. Vincent

def sillycase(n): lenght_n = len(n) lenght_n_2 = int(lenght_n / 2) n_list = list(n) first_half = n_list[:lenght_n_2] first = str.lower(''.join(first_half)) second_half = n_list[lenght_n_2:] second = str.upper(''.join(second_half)) print(first+second)

sillycase.py
def sillycase(n):
    lenght_n = len(n)
    lenght_n_2 = int(lenght_n / 2)
    n_list = list(n)
    first_half = n_list[:lenght_n_2]
    first = str.lower(''.join(first_half))
    second_half = n_list[lenght_n_2:]
    second = str.upper(''.join(second_half))
    print(first+second)

2 Answers

Stuart Wright
Stuart Wright
41,118 Points

You're printing the output instead of returning it :)

Vincent C
Vincent C
1,376 Points

Oh dear... got to take a break now, I guess... Thanks, Stuart. Silly me