You can download this code by clicking the button below.
This code is now available for download.
This function takes two lists of equal length as input, then randomly pairs the elements of the two lists, and returns a list containing these pairs.
Technology Stack : random
Code Type : Function
Code Difficulty : Intermediate
import random
def shuffle_list(arg1, arg2):
if not isinstance(arg1, list) or not isinstance(arg2, list):
raise ValueError("Both arguments must be lists.")
if len(arg1) != len(arg2):
raise ValueError("Both lists must have the same length.")
shuffled = [None] * len(arg1)
random.shuffle(arg1)
random.shuffle(arg2)
for i in range(len(arg1)):
shuffled[i] = (arg1[i], arg2[i])
return shuffled