What exactly does the .join() method do?

后端 未结 9 2545
一向
一向 2020-11-22 10:54

I\'m pretty new to Python and am completely confused by .join() which I have read is the preferred method for concatenating strings.

I tried:

         


        
9条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-22 11:17

    list = ["my", "name", "is", "kourosh"]   
    " ".join(list)
    

    If this is an input, using the JOIN method, we can add the distance between the words and also convert the list to the string.

    This is Python output

    'my name is kourosh'
    

提交回复
热议问题