How can I join a list of string into one string in Python

后端 未结 1 1724
鱼传尺愫
鱼传尺愫 2020-12-12 08:28

I am trying to join a list of strings into one string using .join()method. However, it seems like the result is still the same where the output still producing

相关标签:
1条回答
  • 2020-12-12 08:39

    Add this line at the first line of your .py file:

    from __future__ import print_function
    

    Next, change these lines:

    semua = ' '.join(kata)
    print semua
    

    To:

    semua = ''.join(kata)
    print(semua, end='')
    

    You want to make sure you're not adding spaces and newlines where not needed.

    0 讨论(0)
提交回复
热议问题