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 trial
Larissa Banitt
681 Pointstie a string in Python
Hi, so I"m wondering how to tie together to parts of a string with Python. This is my example: return string[midpoint:].lower + string[:midpoint].upper
They said there was an error in that part of the code, but I don't know where it is.
1 Answer
Trevor Currie
9,289 PointsLarissa,
I'm assuming that this what you want to do:
string = "This is a string."
midpoint = len(string)/2
new_string = string[midpoint:].lower() + string[:midpoint].upper()
Notice that the both upper and lower have parentheses following them. They are methods attached to strings, not attributes, so they need to be called to be used.