I get the following error from the code below
Traceback (most recent call last):
File "C:/Users/h.villeneuve/PycharmProjects/OrderedDict/OrderedDict.py", line 29, in <module>
if tracking[week_pool] < 3:
TypeError: unhashable type: 'list'
assignments: [[]]
So according to a website, i must convert the employee_choices tuple to a list, which i did.
But now it says "expected at most 1 arguments, got 5."
Which can be resolved by Using the str.format method to provide a single string to input.
Am i destroying everything or ...
Is what am i doing is considered as spamming ? If yes please let me know.
So i converted the week_pool to a list, which then give me this error
line 12, in <module>
week_pool = list(range[1, 53])
TypeError: 'type' object is not subscriptable
Traceback (most recent call last):
File "C:/Users/h.villeneuve/PycharmProjects/OrderedDict/OrderedDict.py", line 29, in <module>
if tracking[week_pool] < 3:
TypeError: unhashable type: 'list'
assignments: [[]]
from collections import OrderedDict ids_names = { ("01", "Jean"), ("02", "Claude"), ("03", "Van"), ("04", "Damme"), ("05", "Kristopher"), ("06", "Bianca"), } week_pool = list(range(1, 53)) employee_choices = OrderedDict([ ("01", [1,2,3,4,5]), ("02", [1,2,3,4,5]), ("03", [1,2,3,4,5]), ("04", [1,2,3,4,5]), ("05", [2,3,4,5,6]), ("06", [1,2,3]), ]) tracking = {week_num: 0 for week_num in week_pool} assignments = [ ] for element in employee_choices.items(): assignments.append([ ]) print('assignments: {}'.format(assignments)) for week_num in employee_choices: if tracking[week_pool] < 3: assignments[-1].append(week_pool) tracking[week_num] += 1 if len(assignments[-1]) == 2: break
So according to a website, i must convert the employee_choices tuple to a list, which i did.
But now it says "expected at most 1 arguments, got 5."
Which can be resolved by Using the str.format method to provide a single string to input.
Am i destroying everything or ...
from collections import OrderedDict ids_names = { ("01", "Jean"), ("02", "Claude"), ("03", "Van"), ("04", "Damme"), ("05", "Kristopher"), ("06", "Bianca"), } week_pool = list(range(1, 53)) employee_choices = OrderedDict( ("01", (1,2,3,4,5)), ("02", (1,2,3,4,5)), ("03", (1,2,3,4,5)), ("04", (1,2,3,4,5)), ("05", (2,3,4,5,6)), ) tracking = {week_num: 0 for week_num in week_pool} assignments = [ ] for element in employee_choices.items(): assignments.append([ ]) print('assignments: {}'.format(assignments)) for week_num in employee_choices: if tracking[week_pool] < 3: assignments[-1].append(week_pool) tracking[week_num] += 1 if len(assignments[-1]) == 2: break
Is what am i doing is considered as spamming ? If yes please let me know.
So i converted the week_pool to a list, which then give me this error
line 12, in <module>
week_pool = list(range[1, 53])
TypeError: 'type' object is not subscriptable
from collections import OrderedDict ids_names = { ("01", "Jean"), ("02", "Claude"), ("03", "Van"), ("04", "Damme"), ("05", "Kristopher"), ("06", "Bianca"), } week_pool = list(range[1, 53]) employee_choices = OrderedDict([ ("01", [1,2,3,4,5]), ("02", [1,2,3,4,5]), ("03", [1,2,3,4,5]), ("04", [1,2,3,4,5]), ("05", [2,3,4,5,6]), ("06", [1,2,3]), ]) tracking = {week_num: 0 for week_num in week_pool} assignments = [ ] for element in employee_choices.items(): assignments.append([ ]) print('assignments: {}'.format(assignments)) for week_num in employee_choices: if tracking[week_pool] < 3: assignments[-1].append(week_pool) tracking[week_num] += 1 if len(assignments[-1]) == 2: break