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 trialAndy Bosco
Courses Plus Student 681 PointsGot ['d', 'i', 'm']['S', 'U', 'M'] but need 'dimSUM'
I need help regardless of how I join() add add the strings I can't get them to be "dimSUM". What should I do?
# 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 sillycase(name):
name = "Dimsum"
list_name = list(name)
half = str(list_name[0:3]).lower() + str(list_name[3:8]).upper()
return half
1 Answer
Dan Johnson
40,533 PointsConverting a string to a list results in each character being added as an element. You can slice strings just like lists so you can avoid that issue.
I'm guessing you reassigned name for testing, but either way you'll need to drop that line and find the center index of the string by using the round and len methods.
Andy Bosco
Courses Plus Student 681 PointsAndy Bosco
Courses Plus Student 681 PointsHi Dan, when I tried to convert the String to a List. I got this error "Got '['[', "'", 'd', "'", ',', ' ', "'", 'i', "'", ',', ' ', "'", 'm', "'", ']', '[', "'", 'S', "'", ',', ' ', "'", 'U', "'", ',', ' ', "'", 'M', "'", ']']". I not sure how round() and len() will help in this. Please provide me an insight into this.
At the moment, I can read and understand the Python scripts do. But writing one on my own is a challenge and that's why I come here.
Dan Johnson
40,533 PointsDan Johnson
40,533 PointsNo explicit conversions are required. You can work with strings all the way though.
Here's something to get you started: