+ 3

when we call this function multiple time it make mistakes,

i want to select groups where no 2 elements of the group talk the same language. the problem is with the condition: while res[i][1] == res[i-1][1] can you help me? https://code.sololearn.com/ccQz7O3IvjzS/?ref=app

16th Feb 2019, 8:26 PM
Ahmad Ali
Ahmad Ali - avatar
2 Answers
+ 4
def group (x, y): res = random.sample(seq, y) while len(set([u[1] for u in res])) < y: res = random.sample(seq, y) return res
16th Feb 2019, 8:57 PM
Anna
Anna - avatar
+ 3
it works, thank you Anna
17th Feb 2019, 9:22 AM
Ahmad Ali
Ahmad Ali - avatar