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 trialNikhil Alexander
1,444 Pointsi dint get the right output....for converting the first half into lower case and second half into upper case..
please help me out on this
def sillycase(word):
first_half = int(len(word) % 2) + 1
new1 = word[:first_half].lower()
second_half = int(-first_half)
new2 = word[-1:second_half].upper()
return new1 + new2
1 Answer
Alexander Davison
65,469 PointsYou only need one variable holding the midway index.
def sillycase(string):
halfway = int(len(string) / 2)
first_half = string[:halfway].lower()
second_half = string[halfway:].upper()
return first_half + second_half
I hope this helps!
Happy coding! ~Alex
Dave StSomeWhere
19,870 PointsDave StSomeWhere
19,870 PointsYou also don't need the first_half and second_half variables - I'm quickly becoming a python fan