On Thursday, 29 August 2019 13:25:01 UTC+10, Sayth Renshaw wrote: > Hi > > Trying to find whats changed in this example. Based around work and team > reschuffles. > > So first I created my current teams and then my shuffled teams. > > people = ["Tim","Bill","Sally","Ally","Fred","Fredricka"] > team_number = [1,1,2,2,3,3] > > shuffle_people = ["Fredricka","Bill","Sally","Tim","Ally","Fred"] > shuffle_team_number = [1,1,2,2,3,3] > > Then combine. > > teams = list(zip(people,team_number)) > shuffle_teams = list(zip(shuffle_people, shuffle_team_number)) > > Then I am attempting to compare for change. > > [i for i, j in zip(teams, shuffle_teams) if i != j] > > #Result > [('Tim', 1), ('Ally', 2), ('Fred', 3), ('Fredricka', 3)] > > #Expecting to see > > [('Fredricka', 1),('Tim', 2)] > > What's a working way to go about this? > > Sayth
It looks like Tuples are comparing by position changes not content changes. So this fails too set(shuffle_teams) & set(teams) # {('Bill', 1), ('Fred', 3), ('Sally', 2)} -- https://mail.python.org/mailman/listinfo/python-list