Subtracting two lists in Python

前端 未结 13 1524
一整个雨季
一整个雨季 2020-12-02 15:31

In Python, How can one subtract two non-unique, unordered lists? Say we have a = [0,1,2,1,0] and b = [0, 1, 1] I\'d like to do something like

相关标签:
13条回答
  • 2020-12-02 16:17

    I'm not sure what the objection to a for loop is: there is no multiset in Python so you can't use a builtin container to help you out.

    Seems to me anything on one line (if possible) will probably be helishly complex to understand. Go for readability and KISS. Python is not C :)

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