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 trialEmilio Andere
495 PointsIm really confused
can someone help me with this please
def sillycase(string):
string[:5].lowercased
string[5:].uppercase
sillycase(Treehouse)
2 Answers
Steven Parker
231,275 PointsHere's a few hints:
- you won't know how long the string will be, so you can't used fixed values in the slice
- the names of the functions for changing case are ".lower()" and ".upper()"
- you'll need to combine the two new parts together
- you'll need to "return" the combined result
- you only need to define the function, you don't need to call it yourself
Ryan Cross
5,742 Pointsthis is the challenge that was half upper half lower? heres a hint. you wont know how long it is but you can still cut it in half. if youre still stuck I'll help you.
Emilio Andere
495 Pointsim still stuck, lol
Ryan Cross
5,742 PointsEmilio! In your code you set the string halves with a slice, You have assumed the length of that string. You might not have the strings length right if you guessed. Better to get the length with len() as len(your_string) then cut it in half as len(your_string)/2...this integer will help you indexing the halves of your_string.
another problem is the way you're trying to change cases? the method is lower() or upper() as in half_a_string.lower()
i hope this helps you. If you're struggling with a method like .lower(), upper() or len() go to the python docs they're helpful once you get onto them. Good luck.
Emilio Andere
495 PointsEmilio Andere
495 Pointshow do I combine 2 parts together
Steven Parker
231,275 PointsSteven Parker
231,275 PointsYou can perform string concatenation with the "+" operator.