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 trialdima Dima
901 PointsMay I get some help, How do I solve that?
Create a function named sillycase that takes a string and returns that string with the first half lowercased and the las
# The first half of the string, rounded with round(), should be lowercased.
# The second half should be uppercased.
# E.g. "Treehouse" should come back as "treeHOUSE"
def silycase(list_1):
2 Answers
Steve Hunter
57,712 PointsHi there,
Your method needs to take a parameter which is the word we're going to play around with. I called mine word
as I lack imagination.
Then, determine the length of word
so you can find its half-way point. I assigned the first half and second half into different local variables; you don't need to do that, but I found it clearer. So, I have lower_half
assigned the first part of the word
(from character zero to half its length (rounded)). I do the same for upper_half
to assign the last half of the word
to it. For each of these, I've called lower()
and upper()
where required.
I then add the two together and return the result.
I hope that makes sense. My code isn't the prettiest, but it works - I am sure there are more elegant solutions out there.
Steve.
def sillycase(word):
lower_half = word[0:round(len(word)/2)].lower()
upper_half = word[round(len(word)/2):].upper()
return lower_half + upper_half
dima Dima
901 PointsThank you very much, it helped a lot!!
dima Dima
901 Pointsdima Dima
901 Pointsand the second half with upper cased letters