Ad
  • Custom User Avatar

    but wouldn't it join all the spaces together with an added space?

    It does, doing ' '.join will return its original whitespaces (separator of the values).

    str.split separates the substring into values inside a list. i.e:

    'I  am a boi'.split(' ') ---> ['I', '', 'am', 'a', 'boi']
    ' '.join(['I', '', 'am', 'a', 'boi']) ---> 'I  am a boi'
    

    It'd be different if you leave the args as default tho

    'I  am a boi'.split() ---> ['I', 'am', 'a', 'boi']
    ' '.join(['I', 'am', 'a', 'boi']) ---> 'I am a boi'
    
  • Default User Avatar

    but wouldn't it join all the spaces together with an added space?

    I'm a bit confused. Doesn't split(" ") take away spaces?

  • Custom User Avatar

    Because the solution is using ' '.join

  • Default User Avatar

    I'm confused. How does this copy over the extra spaces? When you use split(" ") doesn't it mess up all of the spacing?

  • Default User Avatar

    Very poorly worded instructions. Had to skip