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 trialAvik Chakraborty
6,621 PointsMy function is not working.
def sillycase(word): return word[:int(len(word)/2)].lower() + word[-int(len(word)/2):].upper()
def sillycase(word):
return word[:int(len(word)/2)].lower() + word[-int(len(word)/2):].upper()
2 Answers
Afloarei Andrei
5,163 Pointstypo error at "......+ word[-int....." remove the '-'
Avik Chakraborty
6,621 Pointsi put it on purpose to make a negetive value. example --> [-2:0] for the last two elements
Afloarei Andrei
5,163 Pointsyou'r code works if a word can be break in exactly 2 peaces like 'word', but if you have a word like 'treehouse' and you do a len('treehouse') / 2 the result will be 4. so your code will print treeOUSE because [-4:] is telling python to print only the las 4 characters from 'treehouse' and [4:] is telling python to print all the characters from the 4th till the end.