name_num = {'Bill': [1, 2, 3, 4], 'Bob': [3, 4, 2], 'Mary': [5, 1], 'Jim':
    [6, 17, 4], 'Kim': [21, 54, 35]}
new_dict = defaultdict(dict)
for name, nums in list(name_num.items()):
    new_dict[len(nums)][name] = nums
print(dict(new_dict))
How to add multiple values to a key in a Python dictionary