Print a list of space-separated elements in Python 3

前端 未结 4 1025
野趣味
野趣味 2020-11-28 04:55

I have a list L of elements, say natural numbers. I want to print them in one line with a single space as a separator. But I don\'t w

4条回答
  •  隐瞒了意图╮
    2020-11-28 05:41

    Joining elements in a list space separated:

    word = ["test", "crust", "must", "fest"]
    word.reverse()
    joined_string = ""
    for w in word:
       joined_string = w + joined_string + " "
    print(joined_string.rstrim())
    

提交回复
热议问题