Python: how to join entries in a set into one string?

前端 未结 8 1179
青春惊慌失措
青春惊慌失措 2020-12-13 17:06

Basically, I am trying to join together the entries in a set in order to output one string. I am trying to use syntax similar to the join function for lists. Here is my atte

8条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-13 17:31

    Nor the set nor the list has such method join, string has it:

    ','.join(set(['a','b','c']))
    

    By the way you should not use name list for your variables. Give it a list_, my_list or some other name because list is very often used python function.

提交回复
热议问题