How do I turn a list of lists of words into a sentence string?

前端 未结 4 1616
南旧
南旧 2021-02-07 00:17

I have this list

[[\'obytay\'], [\'ikeslay\'], [\'ishay\'], [\'artway\']]

where I need it to look like

obytay ikeslay ishay ar         


        
4条回答
  •  一个人的身影
    2021-02-07 00:52

    You have a list in a list so its not working the way you think it should. Your attempt however was absolutely right. Do it as follows:

    ' '.join(word[0] for word in word_list)
    

    where word_list is your list shown above.

    >>> word_list = [['obytay'], ['ikeslay'], ['ishay'], ['artway']]
    >>> print ' '.join(word[0] for word in word_list)
    obytay ikeslay ishay artway
    

    Tobey likes his wart

提交回复
热议问题