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 trialKostas Stankevicius
7,169 PointsCant seem to find whats wrong with my function
Thanks for you help !
def sillycase(string):
half = len(string) // 2
first = string[:one].lower()
second = string[one:].upper()
result = first + second
return result
3 Answers
Bryan Reed
11,747 PointsYou defined the half variable but never used it. Once you put the half variable in the slices it works.
def sillycase(string):
half = len(string) // 2
first = string[:half].lower()
second = string[half:].upper()
result = first + second
return result
andren
28,558 PointsYou just have a typo. When slicing the string you reference a variable called one
which does not exist in your code. If you replace one
with half
which I assume is what you meant to type. Like this:
def sillycase(string):
half = len(string) // 2
first = string[:half].lower()
second = string[half:].upper()
result = first + second
return result
Then your code will work.
Kostas Stankevicius
7,169 PointsThanks a lot, Andren and Brian. My variable for half length was originally called one :( silly mistake