Match two lists of letters in Python

后端 未结 3 1165
感情败类
感情败类 2021-01-16 09:45

How can I match two lists of letters without considering the order of letters appearance in that lists in Python

Eg: Think my first list is [\'a\',\'b\',\'c\',

3条回答
  •  感情败类
    2021-01-16 10:34

    How about:

    # if you don't want to consider duplicates either
    output = set(your_first_list) == set(your_second_list)
    
    # if duplicates matter
    output = sorted(your_first_list) == sorted(your_second_list)
    

提交回复
热议问题