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 trialJoshua Senneff
1,159 PointssillyCase(Sorry for spamming :()
Hello once again Dx I'm sorry, I feel bad for spamming questions. But can someone please explain to me how I'm supposed to do this and exactly why this doesn't work? I looked and everybody else has super long methods and I don't get what else I have to do and why this doesn't work :( I feel like I'm not really learning much from the videos, only when people explain to me the coding challenges and stuff
def sillycase(string):
balla = int(string / 2)
string = ''.join(new_string[:balla].lower(), new_string[balla:].upper())
return string
1 Answer
andren
28,558 PointsThere are two issue:
You need to divide the length of
string
by two in your first line, not divide the string itself.The
join
method is used to convert a list to a string, but what you give it is not actually a list. You just give it two strings as separate arguments.
You could solve this issue by placing the two strings inside a list by wrapping them in square brackets like this:
def sillycase(string):
balla = int(len(string) / 2) # Use len method to get length of string and divide that by 2
string = ''.join([string[:balla].lower(), string[balla:].upper()]) # Pass in a list with the two strings
return string
That would work, but it's more complex than it needs to be. Since you have two strings you can just concatenate them together using the + operator. You don't need to join them or put them in a list or anything like that.
Like this:
def sillycase(string):
balla = int(len(string) / 2) # Use len method to get length of string and divide that by 2
string = string[:balla].lower() + string[balla:].upper() # Concatonate the two strings together
return string
Joshua Senneff
1,159 PointsOh, Okedoke, Thank you so much!
Joshua Senneff
1,159 PointsJoshua Senneff
1,159 PointsOops, I forgot to change the new_string to string. But it's still not working xc