Match two lists of letters in Python

后端 未结 3 1163
感情败类
感情败类 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:19

    You could sort them:

    In [1]: a = list('abcd')
    In [2]: b = list('bcad')
    In [3]: sorted(a) == sorted(b)
    Out[3]: True
    
    In [4]: a == b
    Out[4]: False
    

提交回复
热议问题