• Custom User Avatar

    This code could be refractored into one two lines of code, with list comprehension

  • Custom User Avatar
  • Custom User Avatar

    My suggestion is that "for" can skip some occurencies in "a" due to changes in indices of the elements of "a". And "for" goes through "a" by index (not sure here).
    For example. a=[1, 2, 2, 3], b=[2]
    "for" goes through "a" taking item by it's index. Length is 4 so it should pick 1st, 2nd, 3rd and 4th item.
    2nd step: a[2] is "2", it is in "b", "a" changes to [1, 2, 3]
    3rd step: a[3] is "3", it isn't in "b", "a" remains [1, 2, 3]
    4th step: there's no a[4] so loop ends.

  • Custom User Avatar

    Hello Henfox, I am new here, I think the idea is to create a new list with the difference, if you run that code what it does is to modify the 'a' list

    Your code works but according to the practice it is not what they are asking for.

  • Custom User Avatar

    Read this: https://docs.codewars.com/training/troubleshooting#expected-the-same and your code should only return [2] there, all the other text is part of the tests.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution