Ad
  • Custom User Avatar

    What join() basically do is it takes all items in an list/array and joins them into one string separated by the whatever character you have specified in between the ' ' in ''.join().

    Sometimes it can be an empty string which means all the items in the list will be joined and there will be no spaces in between them as shown in the code above you have shared.

    For example :

    >>> list1 = ['a','b','c','d']
    >>> '-'.join(list1)
    'a-b-c-d'
    
    >>> ''.join(list1)
    'abcd'