Louis I. answered 06/14/19
Computer Science Instructor/Tutor: Real World and Academia Experienced
Well, keep in mind that the join() and split() methods complement each other on the str class ... split() generates a list of "fields" (substrings) based on a token, and join() merges a list of strings in an iterable around a given token or field delimiter ...
It makes more sense in that context: 2 complimentary services offered by str: one returns a list while the other accepts a list.
fields = ['I', 'like', 'Python']
record = '-'.join(fields )
fields=record.split(sep='-')
Also keep in mind that the iterable passed to join() should be limited to str elements ...
Something like this will cause you problems:
nums=[1,2,3]
'-'.join(nums)
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
'-'.join(nums)
TypeError: sequence item 0: expected str instance, int found