submission_id
int32 10
42.5k
| func_code
stringlengths 22
782
| assignment_id
stringlengths 4
23
| func_name
stringlengths 4
23
| description
stringlengths 26
128
| test
stringlengths 45
1.22k
| correct
bool 2
classes | user
stringlengths 36
36
| academic_year
int32 2.02k
2.02k
|
---|---|---|---|---|---|---|---|---|
32,311 | def swap_unique_keys_values(d):
store = {}
di = d
for key in d:
for k in di:
if key == k:
break
if di[k] == d[key]:
continue
else:
store[key] = d[k]
return {v: k for v, k in list(store.items())} | swap_unique_keys_values | swap_unique_keys_values | Swap the keys of a dictionary with its unique values. | assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'} | false | 2f34a0ed-0d6a-447e-8e47-6a90f11d53a7 | 2,016 |
36,756 | def swap_unique_keys_values(d):
store = {}
di = d
for key in d:
for k in di:
if key == k:
break
if di[k] == d[key]:
continue
else:
store[key] = d[k]
return {v: k for v, k in list(store.items())} | swap_unique_keys_values | swap_unique_keys_values | Swap the keys of a dictionary with its unique values. | assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'} | false | 2f34a0ed-0d6a-447e-8e47-6a90f11d53a7 | 2,016 |
21,567 | def swap_unique_keys_values(d):
store = {}
di = d
for key in d:
for k in di:
if key == k:
break
if di[k] == d[key]:
continue
else:
store[key] = d[k]
return {v: k for v, k in list(store.items())} | swap_unique_keys_values | swap_unique_keys_values | Swap the keys of a dictionary with its unique values. | assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'} | false | 2f34a0ed-0d6a-447e-8e47-6a90f11d53a7 | 2,016 |
39,154 | def swap_keys_values(d):
{v: k for k, v in list(d.items())} | swap_keys_values | swap_keys_values | Swap the keys of a dictionary with its values. | assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'} | false | 3e9f1e04-e9fd-4164-8fa5-c7feb1dcc1f5 | 2,016 |
12,496 | def swap_keys_values(d):
{v: k for k, v in list(d.items())} | swap_keys_values | swap_keys_values | Swap the keys of a dictionary with its values. | assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'} | false | 3e9f1e04-e9fd-4164-8fa5-c7feb1dcc1f5 | 2,016 |
2,820 | def swap_keys_values():
return {v: k for k, v in d.items} | swap_keys_values | swap_keys_values | Swap the keys of a dictionary with its values. | assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'} | false | fa7e9f17-de07-4868-ab69-667438d7becd | 2,016 |
15,801 | def swap_keys_values():
return {v: k for k, v in list(d.items())} | swap_keys_values | swap_keys_values | Swap the keys of a dictionary with its values. | assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'} | false | fa7e9f17-de07-4868-ab69-667438d7becd | 2,016 |
14,686 | def swap_keys_values(d):
return {v: k for k, v in list(d.items())} | swap_keys_values | swap_keys_values | Swap the keys of a dictionary with its values. | assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'} | true | fa7e9f17-de07-4868-ab69-667438d7becd | 2,016 |
7,225 | def swap_keys_values(d):
return {v: k for k, v in list(d.items())} | swap_keys_values | swap_keys_values | Swap the keys of a dictionary with its values. | assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'} | true | fa7e9f17-de07-4868-ab69-667438d7becd | 2,016 |
6,665 | def swap_unique_keys_values(d):
l = []
m = []
for v in list(d.items()):
if v in l:
m.append(v)
else:
l.append(v)
return {v: k for k, v in list(d.items()) if v not in m} | swap_unique_keys_values | swap_unique_keys_values | Swap the keys of a dictionary with its unique values. | assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'} | false | fa7e9f17-de07-4868-ab69-667438d7becd | 2,016 |
36,881 | def swap_unique_keys_values(d):
l = []
m = []
for v in list(d.values()):
if v in l:
m.append(v)
else:
l.append(v)
return {v: k for k, v in list(d.items()) if v not in m} | swap_unique_keys_values | swap_unique_keys_values | Swap the keys of a dictionary with its unique values. | assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'} | true | fa7e9f17-de07-4868-ab69-667438d7becd | 2,016 |
37,885 | def swap_unique_keys_values(d):
l = []
m = []
for v in list(d.values()):
if v in l:
m.append(v)
else:
l.append(v)
return {v: k for k, v in list(d.items()) if v not in m} | swap_unique_keys_values | swap_unique_keys_values | Swap the keys of a dictionary with its unique values. | assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'} | true | fa7e9f17-de07-4868-ab69-667438d7becd | 2,016 |
20,534 | def swap_keys_values(my_dict):
d = {v: k for k, v in list(d.items())}
return d | swap_keys_values | swap_keys_values | Swap the keys of a dictionary with its values. | assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'} | false | b0c92748-3b02-4340-a9d8-2ebe9a693531 | 2,016 |
14,551 | def swap_keys_values(my_dict):
d = {v: k for k, v in list(d.items())} | swap_keys_values | swap_keys_values | Swap the keys of a dictionary with its values. | assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'} | false | b0c92748-3b02-4340-a9d8-2ebe9a693531 | 2,016 |
9,277 | def swap_keys_values(my_dict):
my_dict = {v: k for k, v in list(d.items())} | swap_keys_values | swap_keys_values | Swap the keys of a dictionary with its values. | assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'} | false | b0c92748-3b02-4340-a9d8-2ebe9a693531 | 2,016 |
25,600 | def swap_keys_values(my_dict):
my_dict = {v: k for k, v in list(my_dict.items())} | swap_keys_values | swap_keys_values | Swap the keys of a dictionary with its values. | assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'} | false | b0c92748-3b02-4340-a9d8-2ebe9a693531 | 2,016 |
23,336 | def swap_keys_values(my_dict):
my_dict = {v: k for k, v in list(my_dict.items())} | swap_keys_values | swap_keys_values | Swap the keys of a dictionary with its values. | assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'} | false | b0c92748-3b02-4340-a9d8-2ebe9a693531 | 2,016 |
34,017 | def swap_keys_values(my_dict):
my_dict = {v: k for k, v in list(my_dict.items())} | swap_keys_values | swap_keys_values | Swap the keys of a dictionary with its values. | assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'} | false | b0c92748-3b02-4340-a9d8-2ebe9a693531 | 2,016 |
8,309 | def swap_unique_keys_values(d):
new_dict = print(sorted(dict([(v, k) for k, v in d.items() if list(d.
values()).count(v) == 1]))) | swap_unique_keys_values | swap_unique_keys_values | Swap the keys of a dictionary with its unique values. | assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'} | false | f1c26f39-fb4c-4010-aaa3-142fb52f57b9 | 2,016 |
13,626 | def swap_unique_keys_values(d):
new_dict = print(sorted(dict([(v, k) for k, v in d.items() if list(d.
values()).count(v) == 1]))) | swap_unique_keys_values | swap_unique_keys_values | Swap the keys of a dictionary with its unique values. | assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'} | false | f1c26f39-fb4c-4010-aaa3-142fb52f57b9 | 2,016 |
16,299 | def swap_keys_values(d):
swapped_d = {}
for key in d:
swapped_d[d[key]] = key
print(swapped_d) | swap_keys_values | swap_keys_values | Swap the keys of a dictionary with its values. | assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'} | false | 41c113b8-6f57-4003-bed3-3587b2376170 | 2,016 |
22,154 | def swap_keys_values(d):
m = {}
for i in list(d.items()):
m[i[1]] = i[0]
return m | swap_keys_values | swap_keys_values | Swap the keys of a dictionary with its values. | assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'} | true | a49f3af8-fb92-43d5-945c-abc11916e319 | 2,016 |
16,172 | def swap_keys_values(d):
m = {}
for i in list(d.items()):
m[i[1]] = i[0]
return m | swap_keys_values | swap_keys_values | Swap the keys of a dictionary with its values. | assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'} | true | a49f3af8-fb92-43d5-945c-abc11916e319 | 2,016 |
13,577 | def swap_unique_keys_values(d):
m = {}
for i in list(d.items()):
if i[1] not in m:
m[i[1]] = i[0]
return m | swap_unique_keys_values | swap_unique_keys_values | Swap the keys of a dictionary with its unique values. | assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'} | false | a49f3af8-fb92-43d5-945c-abc11916e319 | 2,016 |
20,085 | def swap_keys_values(d):
d = {v: k for k, v in list(d.items())}
return d | swap_keys_values | swap_keys_values | Swap the keys of a dictionary with its values. | assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'} | true | f463a026-5eb4-4a39-a858-3a798215a4ee | 2,016 |
38,305 | def swap_keys_values(d):
d = {v: k for k, v in list(d.items())}
return d | swap_keys_values | swap_keys_values | Swap the keys of a dictionary with its values. | assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'} | true | f463a026-5eb4-4a39-a858-3a798215a4ee | 2,016 |
15,562 | def swap_unique_keys_values(d):
m = {}
for i in list(d.items()):
if i[1].count(d) == 1:
m[i[1]] = i[0]
return m | swap_unique_keys_values | swap_unique_keys_values | Swap the keys of a dictionary with its unique values. | assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'} | false | a49f3af8-fb92-43d5-945c-abc11916e319 | 2,016 |
28,543 | def swap_unique_keys_values(d):
m = {}
for i in list(d.items()):
if list(d.values()).count(i[1]) == 1:
m[i[1]] = i[0]
return m | swap_unique_keys_values | swap_unique_keys_values | Swap the keys of a dictionary with its unique values. | assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'} | true | a49f3af8-fb92-43d5-945c-abc11916e319 | 2,016 |
24,820 | def swap_unique_keys_values(d):
m = {}
for i in list(d.items()):
if d.count(i[1]) == 1:
m[i[1]] = i[0]
return m | swap_unique_keys_values | swap_unique_keys_values | Swap the keys of a dictionary with its unique values. | assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'} | false | a49f3af8-fb92-43d5-945c-abc11916e319 | 2,016 |
32,001 | def swap_unique_keys_values(d):
m = {}
for i in list(d.items()):
if d.count(i[1]) == 1:
m[i[1]] = i[0]
return m | swap_unique_keys_values | swap_unique_keys_values | Swap the keys of a dictionary with its unique values. | assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'} | false | a49f3af8-fb92-43d5-945c-abc11916e319 | 2,016 |
32,226 | def swap_unique_keys_values(d):
m = {}
for i in list(d.items()):
if d.count(i[1]) == 1:
m[i[1]] = i[0]
return m | swap_unique_keys_values | swap_unique_keys_values | Swap the keys of a dictionary with its unique values. | assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'} | false | a49f3af8-fb92-43d5-945c-abc11916e319 | 2,016 |
37,683 | def swap_keys_values(d):
swapped_d = {}
for key in d:
swapped_d[d[key]] = key
print(list(swapped_d.items())) | swap_keys_values | swap_keys_values | Swap the keys of a dictionary with its values. | assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'} | false | 41c113b8-6f57-4003-bed3-3587b2376170 | 2,016 |
10,150 | def swap_keys_values(d):
swapped_d = {}
for key in d:
swapped_d[d[key]] = key
return swapped_d | swap_keys_values | swap_keys_values | Swap the keys of a dictionary with its values. | assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'} | true | 41c113b8-6f57-4003-bed3-3587b2376170 | 2,016 |
5,790 | def swap_keys_values(d):
swapped_d = {}
for key in d:
swapped_d[d[key]] = key
return swapped_d | swap_keys_values | swap_keys_values | Swap the keys of a dictionary with its values. | assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'} | true | 41c113b8-6f57-4003-bed3-3587b2376170 | 2,016 |
11,409 | def swap_keys_values(d):
swapped_d = {}
for key in d:
swapped_d[d[key]] = key
return swapped_d | swap_keys_values | swap_keys_values | Swap the keys of a dictionary with its values. | assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'} | true | 41c113b8-6f57-4003-bed3-3587b2376170 | 2,016 |
6,414 | def swap_keys_values(d):
{v: k for k, v in list(d.items())} | swap_keys_values | swap_keys_values | Swap the keys of a dictionary with its values. | assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'} | false | e8eb24cb-1a57-439b-8705-aed3cec25793 | 2,016 |
14,315 | def swap_keys_values(d):
return {v: k for k, v in list(d.items())} | swap_keys_values | swap_keys_values | Swap the keys of a dictionary with its values. | assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'} | true | e8eb24cb-1a57-439b-8705-aed3cec25793 | 2,016 |
23,765 | def swap_keys_values(d):
return {v: k for k, v in list(d.items())} | swap_keys_values | swap_keys_values | Swap the keys of a dictionary with its values. | assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'} | true | e8eb24cb-1a57-439b-8705-aed3cec25793 | 2,016 |
4,188 | def swap_keys_values(d):
return {v: k for k, v in list(d.items())} | swap_keys_values | swap_keys_values | Swap the keys of a dictionary with its values. | assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'} | true | e8eb24cb-1a57-439b-8705-aed3cec25793 | 2,016 |
5,024 | def swap_keys_values(x):
for a in d:
e[d[value]] = e[d[key]] | swap_keys_values | swap_keys_values | Swap the keys of a dictionary with its values. | assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'} | false | 93426de2-87e4-4c00-9910-de51627bd576 | 2,016 |
29,111 | def swap_keys_values(x):
for a in d:
e[d[value]] = e[d[key]]
return e | swap_keys_values | swap_keys_values | Swap the keys of a dictionary with its values. | assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'} | false | 93426de2-87e4-4c00-9910-de51627bd576 | 2,016 |
6,053 | def swap_keys_values(d):
{v: k for k, v in list(d.items())} | swap_keys_values | swap_keys_values | Swap the keys of a dictionary with its values. | assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'} | false | 3e9f1e04-e9fd-4164-8fa5-c7feb1dcc1f5 | 2,016 |
21,464 | def swap_keys_values(d):
{v: k for k, v in list(d.items())} | swap_keys_values | swap_keys_values | Swap the keys of a dictionary with its values. | assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'} | false | 3e9f1e04-e9fd-4164-8fa5-c7feb1dcc1f5 | 2,016 |
40,463 | def swap_keys_values(d):
{v: k for k, v in list(d.items())} | swap_keys_values | swap_keys_values | Swap the keys of a dictionary with its values. | assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'} | false | 3e9f1e04-e9fd-4164-8fa5-c7feb1dcc1f5 | 2,016 |
16,815 | def swap_keys_values(d):
return {v: k for k, v in list(d.items())} | swap_keys_values | swap_keys_values | Swap the keys of a dictionary with its values. | assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'} | true | 3e9f1e04-e9fd-4164-8fa5-c7feb1dcc1f5 | 2,016 |
5,056 | def swap_keys_values(d):
return {v: k for k, v in list(d.items())} | swap_keys_values | swap_keys_values | Swap the keys of a dictionary with its values. | assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'} | true | 3e9f1e04-e9fd-4164-8fa5-c7feb1dcc1f5 | 2,016 |
29,807 | def swap_unique_keys_values(d):
return {v: k for k, v in list(d.items()) if list(d.avlues()).count(v) == 1} | swap_unique_keys_values | swap_unique_keys_values | Swap the keys of a dictionary with its unique values. | assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'} | false | b3fb7be5-b8f9-4b08-be4d-66eb3fcb7782 | 2,016 |
24,276 | def swap_unique_keys_values(d):
return {v: k for k, v in list(d.items()) if list(d.values()).count(v) == 1} | swap_unique_keys_values | swap_unique_keys_values | Swap the keys of a dictionary with its unique values. | assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'} | true | b3fb7be5-b8f9-4b08-be4d-66eb3fcb7782 | 2,016 |
10,584 | def swap_unique_keys_values(d):
return {v: k for k, v in list(d.items()) if list(d.values()).count(v) == 1} | swap_unique_keys_values | swap_unique_keys_values | Swap the keys of a dictionary with its unique values. | assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'} | true | b3fb7be5-b8f9-4b08-be4d-66eb3fcb7782 | 2,016 |
20,139 | def swap_unique_keys_values(d):
return {v: k for k, v in list(d.items()) if list(d.values()).count(v) == 1} | swap_unique_keys_values | swap_unique_keys_values | Swap the keys of a dictionary with its unique values. | assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'} | true | b3fb7be5-b8f9-4b08-be4d-66eb3fcb7782 | 2,016 |
18,286 | def swap_unique_keys_values(in_dict):
out_dict = {}
blist = set()
for k, t in list(in_dict.items()):
if t in out_dict:
blist.update([v])
del out_dict[v]
elif v not in blacklist:
out_dict[v] = k | swap_unique_keys_values | swap_unique_keys_values | Swap the keys of a dictionary with its unique values. | assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'} | false | 11fcbbcf-716f-4e92-ab7c-407d4712c9e8 | 2,016 |
3,997 | def swap_unique_keys_values(in_dict):
out_dict = {}
blist = set()
for k, t in list(in_dict.items()):
if t in out_dict:
blist.update([v])
del out_dict[v]
elif v not in blacklist:
out_dict[v] = k
return out_dict | swap_unique_keys_values | swap_unique_keys_values | Swap the keys of a dictionary with its unique values. | assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'} | false | 11fcbbcf-716f-4e92-ab7c-407d4712c9e8 | 2,016 |
42,182 | def swap_unique_keys_values(in_dict):
out_dict = {}
blist = set()
for k, t in list(in_dict.items()):
if t in out_dict:
blist.update([v])
del out_dict[v]
elif t not in blacklist:
out_dict[v] = k
return out_dict | swap_unique_keys_values | swap_unique_keys_values | Swap the keys of a dictionary with its unique values. | assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'} | false | 11fcbbcf-716f-4e92-ab7c-407d4712c9e8 | 2,016 |
30,467 | def swap_unique_keys_values(in_dict):
out_dict = {}
blist = set()
for k, t in list(in_dict.items()):
if t in out_dict:
blist.update([v])
del out_dict[v]
elif t not in blist:
out_dict[v] = k
return out_dict | swap_unique_keys_values | swap_unique_keys_values | Swap the keys of a dictionary with its unique values. | assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'} | false | 11fcbbcf-716f-4e92-ab7c-407d4712c9e8 | 2,016 |
21,192 | def swap_unique_keys_values(in_dict):
out_dict = {}
blist = set()
for k, t in list(in_dict.items()):
if t in out_dict:
blist.update([t])
del out_dict[t]
elif t not in blist:
out_dict[v] = k
return out_dict | swap_unique_keys_values | swap_unique_keys_values | Swap the keys of a dictionary with its unique values. | assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'} | false | 11fcbbcf-716f-4e92-ab7c-407d4712c9e8 | 2,016 |
13,012 | def swap_unique_keys_values(in_dict):
out_dict = {}
blist = set()
for k, t in list(in_dict.items()):
if t in out_dict:
blist.update([t])
del out_dict[t]
elif t not in blist:
out_dict[t] = k
return out_dict | swap_unique_keys_values | swap_unique_keys_values | Swap the keys of a dictionary with its unique values. | assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'} | true | 11fcbbcf-716f-4e92-ab7c-407d4712c9e8 | 2,016 |
41,252 | def swap_unique_keys_values(in_dict):
out_dict = {}
blist = set()
for k, t in list(in_dict.items()):
if t in out_dict:
blist.update([t])
del out_dict[t]
elif t not in blist:
out_dict[t] = k
return out_dict | swap_unique_keys_values | swap_unique_keys_values | Swap the keys of a dictionary with its unique values. | assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'} | true | 11fcbbcf-716f-4e92-ab7c-407d4712c9e8 | 2,016 |
7,627 | def swap_unique_keys_values(in_dict):
out_dict = {}
blist = set()
for k, t in list(in_dict.items()):
if t in out_dict:
blist.update([t])
del out_dict[t]
elif t not in blist:
out_dict[t] = k
return out_dict | swap_unique_keys_values | swap_unique_keys_values | Swap the keys of a dictionary with its unique values. | assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'} | true | 11fcbbcf-716f-4e92-ab7c-407d4712c9e8 | 2,016 |
41,173 | def swap_unique_keys_values(dick):
newdick = {}
for k, v in list(dick.items()):
if v not in newdick:
newdick[v] = k
return newdick | swap_unique_keys_values | swap_unique_keys_values | Swap the keys of a dictionary with its unique values. | assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'} | false | 4b622395-1c2b-4a5d-ba03-c6e0e0ef2dd7 | 2,016 |
7,230 | def swap_unique_keys_values(dick):
newdick = {}
for k, v in list(dick.items()):
if v not in newdick:
newdick[v] = k
return newdick | swap_unique_keys_values | swap_unique_keys_values | Swap the keys of a dictionary with its unique values. | assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'} | false | 4b622395-1c2b-4a5d-ba03-c6e0e0ef2dd7 | 2,016 |
15,494 | def swap_unique_keys_values(dick):
newdick = {}
for k, v in list(dick.items()):
if list(dick.values()).count(v) == 1:
newdick[v] = k
return newdick | swap_unique_keys_values | swap_unique_keys_values | Swap the keys of a dictionary with its unique values. | assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'} | true | 4b622395-1c2b-4a5d-ba03-c6e0e0ef2dd7 | 2,016 |
26,643 | def swap_unique_keys_values(dick):
newdick = {}
for k, v in list(dick.items()):
if [v for v in list(dick.values())].count(v) == 1:
newdick[v] = k
return newdick | swap_unique_keys_values | swap_unique_keys_values | Swap the keys of a dictionary with its unique values. | assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'} | true | 4b622395-1c2b-4a5d-ba03-c6e0e0ef2dd7 | 2,016 |
37,376 | def swap_unique_keys_values(dick):
newdick = {}
for k, v in list(dick.items()):
if [v for v in list(dick.values())].count(v) == 1:
newdick[v] = k
return newdick | swap_unique_keys_values | swap_unique_keys_values | Swap the keys of a dictionary with its unique values. | assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'} | true | 4b622395-1c2b-4a5d-ba03-c6e0e0ef2dd7 | 2,016 |
23,328 | def swap_keys_values():
return {v: k for k, v in list(d.items())} | swap_keys_values | swap_keys_values | Swap the keys of a dictionary with its values. | assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'} | false | 4b622395-1c2b-4a5d-ba03-c6e0e0ef2dd7 | 2,016 |
21,265 | def swap_keys_values(d):
return {v: k for k, v in list(d.items())} | swap_keys_values | swap_keys_values | Swap the keys of a dictionary with its values. | assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'} | true | 4b622395-1c2b-4a5d-ba03-c6e0e0ef2dd7 | 2,016 |
14,681 | def swap_keys_values(d):
return {v: k for k, v in list(d.items())} | swap_keys_values | swap_keys_values | Swap the keys of a dictionary with its values. | assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'} | true | 4b622395-1c2b-4a5d-ba03-c6e0e0ef2dd7 | 2,016 |
37,877 | def swap_keys_values(d):
return {v: k for k, v in list(d.items())} | swap_keys_values | swap_keys_values | Swap the keys of a dictionary with its values. | assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'} | true | 4b622395-1c2b-4a5d-ba03-c6e0e0ef2dd7 | 2,016 |
39,382 | def swap_keys_values(d):
d = {'cat': 2, 'dog': 7, 'horse': 9, 'whale': 14}
for key, value in d:
{value: key for key, value in list(d.items())}
print(swap_keys_values(d)) | swap_keys_values | swap_keys_values | Swap the keys of a dictionary with its values. | assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'} | false | f98e9d61-9e86-4fed-86db-3cf718c5962d | 2,016 |
25,978 | def swap_keys_values(d):
d = {'cat': 2, 'dog': 7, 'horse': 9, 'whale': 14}
for key, value in d:
{value: key for key, value in list(d.items())}
print(swap_keys_values(d)) | swap_keys_values | swap_keys_values | Swap the keys of a dictionary with its values. | assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'} | false | f98e9d61-9e86-4fed-86db-3cf718c5962d | 2,016 |
8,835 | def swap_keys_values(d):
d = {'cat': 2, 'dog': 7, 'horse': 9, 'whale': 14}
for key, value in d:
{value: key for key, value in list(d.items())}
print(swap_keys_values(d)) | swap_keys_values | swap_keys_values | Swap the keys of a dictionary with its values. | assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'} | false | f98e9d61-9e86-4fed-86db-3cf718c5962d | 2,016 |
34,742 | def swap_keys_values(d):
reverse = {}
for k, v in list(d.items()):
reverse[v] = k
return reverse | swap_keys_values | swap_keys_values | Swap the keys of a dictionary with its values. | assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'} | true | 46954879-c4e4-4ce6-87d4-00184c62b522 | 2,016 |
11,085 | def swap_keys_values(d):
reverse = {}
for k, v in list(d.items()):
reverse[v] = k
return reverse | swap_keys_values | swap_keys_values | Swap the keys of a dictionary with its values. | assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'} | true | 46954879-c4e4-4ce6-87d4-00184c62b522 | 2,016 |
29,373 | def swap_keys_values(d):
reverse = {}
for k, v in list(d.items()):
reverse[v] = k
return reverse | swap_keys_values | swap_keys_values | Swap the keys of a dictionary with its values. | assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'} | true | 46954879-c4e4-4ce6-87d4-00184c62b522 | 2,016 |
8,580 | def swap_unique_keys_values(d):
a = [v for k, v in list(d.items())]
b = [c for c in a if a.count(c) == 1]
return {v: k for k, v in list(d.items()) if v in b} | swap_unique_keys_values | swap_unique_keys_values | Swap the keys of a dictionary with its unique values. | assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'} | true | 3e9f1e04-e9fd-4164-8fa5-c7feb1dcc1f5 | 2,016 |
11,392 | def swap_unique_keys_values(d):
a, b = [v for k, v in list(d.items())], [c for c in a if a.count(c) == 1]
return {v: k for k, v in list(d.items()) if v in b} | swap_unique_keys_values | swap_unique_keys_values | Swap the keys of a dictionary with its unique values. | assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'} | false | 3e9f1e04-e9fd-4164-8fa5-c7feb1dcc1f5 | 2,016 |
6,637 | def swap_unique_keys_values(d):
a = [v for k, v in list(d.items())]
b = [c for c in a if a.count(c) == 1]
return {v: k for k, v in list(d.items()) if v in b} | swap_unique_keys_values | swap_unique_keys_values | Swap the keys of a dictionary with its unique values. | assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'} | true | 3e9f1e04-e9fd-4164-8fa5-c7feb1dcc1f5 | 2,016 |
4,402 | def swap_unique_keys_values(d):
a = [v for k, v in list(d.items())]
b = [c for c in a if a.count(c) == 1]
return {v: k for k, v in list(d.items()) if v in b} | swap_unique_keys_values | swap_unique_keys_values | Swap the keys of a dictionary with its unique values. | assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'} | true | 3e9f1e04-e9fd-4164-8fa5-c7feb1dcc1f5 | 2,016 |
32,812 | def swap_unique_keys_values(d):
m = {}
for i in list(d.items()):
if list(d.values()).count(i[1]) == 1:
m[i[1]] = i[0]
return m | swap_unique_keys_values | swap_unique_keys_values | Swap the keys of a dictionary with its unique values. | assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'} | true | a49f3af8-fb92-43d5-945c-abc11916e319 | 2,016 |
41,014 | def swap_unique_keys_values(d):
m = {}
for i in list(d.items()):
if list(d.values()).count(i[1]) == 1:
m[i[1]] = i[0]
return m | swap_unique_keys_values | swap_unique_keys_values | Swap the keys of a dictionary with its unique values. | assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'} | true | a49f3af8-fb92-43d5-945c-abc11916e319 | 2,016 |
22,779 | def swap_keys_values(in_dict):
out_dict = {}
for k, v in list(in_dict.items()):
out_dict[v] = k
return out_dict | swap_keys_values | swap_keys_values | Swap the keys of a dictionary with its values. | assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'} | true | c0bd18cc-b8fa-4b4a-87c2-5e1043d7ff6c | 2,016 |
39,415 | def swap_unique_keys_values(in_dict):
out_dict = {}
list = set()
for k, v in in_dict.items:
if v in out_dict():
list.append([v])
del out_dict[v]
elif v not in list:
out_dict[v] = k
return out_dict | swap_unique_keys_values | swap_unique_keys_values | Swap the keys of a dictionary with its unique values. | assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'} | false | c0bd18cc-b8fa-4b4a-87c2-5e1043d7ff6c | 2,016 |
11,746 | def swap_unique_keys_values(in_dict):
out_dict = {}
list = set()
for k, v in in_dict.items:
if v in out_dict():
list.update([v])
del out_dict[v]
elif v not in list:
out_dict[v] = k
return out_dict | swap_unique_keys_values | swap_unique_keys_values | Swap the keys of a dictionary with its unique values. | assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'} | false | c0bd18cc-b8fa-4b4a-87c2-5e1043d7ff6c | 2,016 |
18,413 | def swap_unique_keys_values(d):
new_dict = dict([(v, k) for k, v in list(d.items()) if list(d.values())
.count(v) == 1])
print(new_dict) | swap_unique_keys_values | swap_unique_keys_values | Swap the keys of a dictionary with its unique values. | assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'} | false | c0bd18cc-b8fa-4b4a-87c2-5e1043d7ff6c | 2,016 |
16,282 | def swap_unique_keys_values(d):
return dict([(v, k) for k, v in list(d.items()) if list(d.values()).
count(v) == 1]) | swap_unique_keys_values | swap_unique_keys_values | Swap the keys of a dictionary with its unique values. | assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'} | true | c0bd18cc-b8fa-4b4a-87c2-5e1043d7ff6c | 2,016 |
32,420 | def swap_unique_keys_values(d):
return dict([(v, k) for k, v in list(d.items()) if list(d.values()).
count(v) == 1]) | swap_unique_keys_values | swap_unique_keys_values | Swap the keys of a dictionary with its unique values. | assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'} | true | c0bd18cc-b8fa-4b4a-87c2-5e1043d7ff6c | 2,016 |
8,900 | def swap_keys_values(d):
{v: k for k, v in list(d.items())}
return d | swap_keys_values | swap_keys_values | Swap the keys of a dictionary with its values. | assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'} | false | 9550e418-a019-49c2-a2e9-8322a300fb6f | 2,016 |
2,624 | def swap_keys_values(d):
new_dict = {v: k for k, v in list(d.items())}
return new_dict | swap_keys_values | swap_keys_values | Swap the keys of a dictionary with its values. | assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'} | true | 9550e418-a019-49c2-a2e9-8322a300fb6f | 2,016 |
19,894 | def swap_keys_values(d):
new_dict = {v: k for k, v in list(d.items())}
return new_dict | swap_keys_values | swap_keys_values | Swap the keys of a dictionary with its values. | assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'} | true | 9550e418-a019-49c2-a2e9-8322a300fb6f | 2,016 |
14,989 | def swap_keys_values(d):
return dict([(v, k) for k, v in list(d.items())]) | swap_keys_values | swap_keys_values | Swap the keys of a dictionary with its values. | assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'} | true | c0bd18cc-b8fa-4b4a-87c2-5e1043d7ff6c | 2,016 |
27,506 | def swap_keys_values(d):
return dict([(v, k) for k, v in list(d.items())]) | swap_keys_values | swap_keys_values | Swap the keys of a dictionary with its values. | assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'} | true | c0bd18cc-b8fa-4b4a-87c2-5e1043d7ff6c | 2,016 |
1,042 | def swap_keys_values(d):
return dict([(v, k) for k, v in list(d.items())]) | swap_keys_values | swap_keys_values | Swap the keys of a dictionary with its values. | assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'} | true | c0bd18cc-b8fa-4b4a-87c2-5e1043d7ff6c | 2,016 |
28,611 | def swap_unique_keys_values(d):
tempd = {}
for k, v in list(d.items()):
if d.count(v) < 2:
tempd = {k: v}
new_dict = {v: k for k, v in list(tempd.items())}
return new_dict | swap_unique_keys_values | swap_unique_keys_values | Swap the keys of a dictionary with its unique values. | assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'} | false | 9550e418-a019-49c2-a2e9-8322a300fb6f | 2,016 |
28,715 | def swap_unique_keys_values(d):
tempd = {}
for k, v in list(d.items()):
if v.count(v) < 2:
tempd = {k: v}
new_dict = {v: k for k, v in list(tempd.items())}
return new_dict | swap_unique_keys_values | swap_unique_keys_values | Swap the keys of a dictionary with its unique values. | assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'} | false | 9550e418-a019-49c2-a2e9-8322a300fb6f | 2,016 |
24,892 | def swap_unique_keys_values(d):
tempd = {}
for k, v in list(d.items()):
if v.count(str(v)) < 2:
tempd = {k: v}
new_dict = {v: k for k, v in list(tempd.items())}
return new_dict | swap_unique_keys_values | swap_unique_keys_values | Swap the keys of a dictionary with its unique values. | assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'} | false | 9550e418-a019-49c2-a2e9-8322a300fb6f | 2,016 |
11,468 | def swap_unique_keys_values(d):
tempd = {}
tempd = {k: v for k, v in list(d.items()) if v.count(v) < 2}
new_dict = {v: k for k, v in list(tempd.items())}
return new_dict | swap_unique_keys_values | swap_unique_keys_values | Swap the keys of a dictionary with its unique values. | assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'} | false | 9550e418-a019-49c2-a2e9-8322a300fb6f | 2,016 |
3,915 | def swap_unique_keys_values(d):
tempd = {}
tempd = {k: v for k, v in list(d.items()) if str(v).count(v) < 2}
new_dict = {v: k for k, v in list(tempd.items())}
return new_dict | swap_unique_keys_values | swap_unique_keys_values | Swap the keys of a dictionary with its unique values. | assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'} | false | 9550e418-a019-49c2-a2e9-8322a300fb6f | 2,016 |
31,179 | def swap_unique_keys_values(d):
tempd = {}
tempd = {k: v for k, v in list(d.items()) if list(v).count(v) < 2}
new_dict = {v: k for k, v in list(tempd.items())}
return new_dict | swap_unique_keys_values | swap_unique_keys_values | Swap the keys of a dictionary with its unique values. | assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'} | false | 9550e418-a019-49c2-a2e9-8322a300fb6f | 2,016 |
31,653 | def swap_unique_keys_values(d):
tempd = {}
tempd = {k: v for k, v in list(d.items()) if list(v).count(v) < 2}
new_dict = {v: k for k, v in list(tempd.items())}
return new_dict | swap_unique_keys_values | swap_unique_keys_values | Swap the keys of a dictionary with its unique values. | assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'} | false | 9550e418-a019-49c2-a2e9-8322a300fb6f | 2,016 |
37,954 | def swap_unique_keys_values(d):
tempd = {}
tempd = {k: v for k, v in list(d.items()) if list(v).count(v) < 2}
new_dict = {v: k for k, v in list(tempd.items())}
return new_dict | swap_unique_keys_values | swap_unique_keys_values | Swap the keys of a dictionary with its unique values. | assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'} | false | 9550e418-a019-49c2-a2e9-8322a300fb6f | 2,016 |
32,713 | def swap_keys_values(d):
new_dict = dict([(v, k) for k, v in list(d.items())])
return new_dict | swap_keys_values | swap_keys_values | Swap the keys of a dictionary with its values. | assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'} | true | 6f8302a0-5974-4b36-a8e9-6b3968a8fce1 | 2,016 |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.