import random
from copy import deepcopy
def member_shuffle(input_list) :
tmp_list = deepcopy(input_list)
random.shuffle(tmp_list)
return tmp_list
def member_move(input_list) :
step = random.randint(1,len(input_list)-1)
return (input_list + input_list)[step:step+len(input_list)]
member_list = ['a','b','c','d','e','f']
shuffled_member_list = member_shuffle(member_list)
moved_member_list = member_move(shuffled_member_list)
for member in member_list :
give_to = moved_member_list[shuffled_member_list.index(member)]
print('{} 送禮給 {}'.format(member,give_to))
輸出:
a 送禮給 b
b 送禮給 a
c 送禮給 e
d 送禮給 f
e 送禮給 c
f 送禮給 d
理科聖誕節要交換禮物這麼麻煩
不能線上用個抽籤系統就好嗎