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 trialMohammad Aslam
6,053 PointsConverting String to List to String
Can someone please advise why this is not correct? I have the function which is supposed to turn a string into a string with the first half lower case and the second half upper case. I have done this by converting the string into a list and then re-joining the combined list.
Would appreciate your help. My apologies if the parentheses in the function are confusing.
def sillycase(string):
list1 = list(string)
first = list1[0:(int((len(list1)/2)+1))].lower()
second = list1[(int((len(list1)/2)+1)):].upper()
return "".join(first + second)
2 Answers
Stuart McIntosh
Python Web Development Techdegree Graduate 22,874 Pointshi there, couple of pointers.
- list has no .upper() or .lower() attributes
- Just use the 'string' passed in as a string is mutable
- Revisit your len(string) / 2 + 1 : no need for the + 1
Hope that helps.
Mohammad Aslam
6,053 PointsThanks, I passed the challenge.
No need to convert the string into a list.