因此給出隨機的人員列表,每週的日子偏好列表,例如每個子列表中的7個位置,第一個位置值6個點,第二個5個,第三個4個,第四4,第三個2,第二個1,最後沒有得到任何優先點:列表和字符串的元組
days_week=['mon','tues','wed','thurs','fri','sat','sun']
random_day_list=[['sat','sun','wed','thurs','mon','tues','fri'],['mon','fri','sat','sun','wed','thurs','tues'],['tues','fri','sun','sat','wed','thurs','mon']]
功能我想提出應該輸出最高得分一天的元組,總點的列表每天按days_week的順序排列。從上面的輸出將是:
('sat',[8,7,8,5,10,14])
星期六有14點,所以這是在這種情況下最優選的一天。
的到目前爲止,香港專業教育學院的想法:
day_dictionary={'mon':0,'tues':0,'wed':0,'thurs':0,'fri':0,'sat':0,'sun':0}
for i in random_day_list:
# getting into the sublist
for j in i:
if j in day_dictionary:
# stuck here: whatever position j is in (0,1,2,3,4,5,6) if its
0 add 6, 1 add 5, and so on, to day_dictionary[j]
,我不能導入除了數學巫婆我懷疑我需要
聞起來像作業.. – asheeshr
它的一個問題,從一本python書,難倒我,所以雅作業,我猜想,但沒有指派我只是這樣做 – pythonnoob