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 trialEnzo Cnop
5,157 PointsBummer! Couldn't find 'sillycase'. Why is this occurring?
def sillycase(string):
count = round(len(string)/2)
first_half = (string[:mid]).lower()
second_half = (string[mid:]).upper()
return first_half + second_half
Above is my code. Why is the compiler telling me 'couldn't find sillycase'? Also, a bunch of examples in questions use various stand in figures for the "(string[:mid]).lower()" portion. Some use 'half' some use 'middle' some use 'mid'. I'm confused as to how python knows these words / if I missed something in the video that explains how you can substitute integers for other variables in the slice notation.
def sillycase(string):
count = round(len(string)/2)
first_half = (string[:mid]).lower()
second_half = (string[mid:]).upper()
return first_half + second_half
1 Answer
James Shi
8,942 Pointsmid is a variable. You want to declare mid in the first line of your function instead of count, which will fix your issue. You can always substitute an integer for a variable. The slice notation is irrelevant to whether you could use variables or not.
Enzo Cnop
5,157 PointsEnzo Cnop
5,157 PointsThank you! I didn't realize you could use variables in slice notation. This was the missing piece.