how do i insert spaces into a string using the range function?

后端 未结 3 1487
再見小時候
再見小時候 2021-02-15 15:37

If I have a string, for example which reads: \'Hello how are you today Joe\' How am I able to insert spaces into it at regular intervals? So for example I want to insert spaces

3条回答
  •  借酒劲吻你
    2021-02-15 16:23

    Just another way to do it

    >>> ''.join(e if (i+1)%2 else e+" " for (i,e) in enumerate(list(s)))
    'He ll o  ho w  ar e  yo u  to da y  Jo e'
    

提交回复
热议问题