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 trialMikael D.D
Courses Plus Student 2,080 PointsQuiz question 2 on review split and join
Review Split and Join Quiz
Question 1 of 2
If I had a list and I wanted to turn it into a string by combining each value together with a specified separator.
What method would I use?
A split. It's on lists.
B join. It's on lists.
C split. It's on strings.
D join. It's on strings.
What do we mean by: "I'ts on lists", "its on strings"
My brain is having a hard time parsing this question. Can someone please explain to me the "Its on" part...not sure i get it
So far, my understanding is that the Join method will output each element of a list as a clean compact string that we can display to a user. On the other hand, the split method does the opposite it turns a string into a list that we can play with.
2 Answers
Steven Parker
231,236 PointsMethods are associated with different kinds of things. The phrase "it's on" is being used here to refer to the thing the method is associated with. This would also be the thing you would connect the method to using the membership operator (a dot: "."). So for generic examples:
"a string".method(["a", "list"]) # this method is "on" strings, and takes a list argument
["a", "list"].method("a string") # this method is "on" lists, and takes a string argument
Since you know the name of the method, that puts you halfway there. Now if you identify the syntax you can pick the correct answer.
KRIS NIKOLAISEN
54,971 PointsIn the Python docs join() is listed as a string method. It's kind of a trick question because you'd expect it to be a list method for what you stated above. "It's on" is another way of saying is a string/list method.
Mikael D.D
Courses Plus Student 2,080 PointsI need to cultivate the lifetime habit of reading the Python Doc related to each lesson.
Thank you Kris, for both the link and the hint ;)
Mikael D.D
Courses Plus Student 2,080 PointsMikael D.D
Courses Plus Student 2,080 PointsCrystal clear explanation as usual...Thank you Steven