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 trialMichael Morale
2,702 PointsSillycase business.
I understand what it's asking, but I don't really know how to put it down. I know to use the (//2) to divide the word as well as the .upper and .lower but that's all I got. I know the int( function but not sure how it applies here. Any pointers?
def sillycase(word):
(//2 word.upper) + (//2 word.lower)
2 Answers
Seth Gorham
5,016 PointsHi Michael, I was able to get this to work by using the len() function and slices.
word = "Revolution"
# Can't divide a string by an integer, so we get half the length
halfway = len(word) // 2
# Then use the halfway as an index in a slice, adding the upper or lower functions to the end
word[0:halfway].lower()
word[halfway:].upper()
A lot of this was trial and error running individual commands in the workspace.
Hope this helps and good luck!
Michael Morale
2,702 PointsI tried that and couldn't get it to work.