秘密圣诞老人-名单更新

时间:2019-12-18 08:29:34

标签: python python-3.x jupyter-notebook

我试图在这里编写自己的秘密圣诞老人代码。我已经从“数据框”的列中创建了一个名称主列表。我的程序似乎可以运行。...但仅一次

我的问题是- 主列表不断更新。

注意:我正在使用Jupyter Notebook

def my_own_ss(list_of_names):
    #to_list = list_of_names
    from_list = list_of_names
    result = []

    for gifter in list_of_names:

        # Remove the current name(chooser):
        from_list.pop(list_of_names.index(gifter))

        #Pick a random person to gift to from the 1st list as the giver's name has been removed.
        #So he won't be selected for himself.
        chosen_person = random.choice(from_list)

        #Pair them up.
        result.append((gifter,chosen_person))

    return result

name_list = data['Resource Name'].tolist()

现在,在提出使用“复制”模块的建议后,我得到了弹出索引错误。

0 个答案:

没有答案