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 trialZac Serhus
741 PointsHow do I use the help() in python to better understand "split" and "join"? Both methods, but seem to format differently.
When typing
help(split)
or
help(join)
Errors were popping up. I think I got one to work with some combination, so hopefully the above examples don't confuse the question.
Also, could anyone shine some light on why the methods split() and join() formatted differently?
Thank you!!
2 Answers
Stuart Wright
41,120 PointsThese are string methods, so you can access the help using the following commands:
help(str.join)
help(str.split)
asd asdf
Courses Plus Student 298 PointsIn the python shell:
$ my_string = ''
$ help(my_string.split)
then
$ help("".join)
Edit: I've always wanted to know why .join()
in python takes the arguments in a different spot than .split()
, especially since in JavaScript, for example, it's the other way around and it works like ˙my_list.join(', ')˙. But I haven't been able to find an answer.
Zac Serhus
741 PointsHopefully we can find some enlightenment down the line.
Thank you
Zac Serhus
741 PointsZac Serhus
741 PointsGot it. Thanks