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
7,362
def swap_keys_values(d): for i in d: j[d[i]] = i return j
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
6668ebd6-a850-4666-b8cc-5c934a67601a
2,016
19,911
def swap_keys_values(d): for i in d: j[d[i]] = i return j
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
6668ebd6-a850-4666-b8cc-5c934a67601a
2,016
39,019
def swap_unique_keys_values(d): new_d = {} doubles = set() for k, v in list(d.items()): if v in new_d: doubles.add(v) new_d[v] = k for k in doubles: del new_d[k] return new_d
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
91bbbbbf-cad8-4507-9c4d-c7cfe0ebc210
2,016
2,668
def swap_unique_keys_values(d): new_d = {} doubles = set() for k, v in list(d.items()): if v in new_d: doubles.add(v) new_d[v] = k for k in doubles: del new_d[k] return new_d
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
91bbbbbf-cad8-4507-9c4d-c7cfe0ebc210
2,016
37,624
def swap_unique_keys_values(d): new_d = {} doubles = set() for k, v in list(d.items()): if v in new_d: doubles.add(v) new_d[v] = k for k in doubles: del new_d[k] return new_d
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
91bbbbbf-cad8-4507-9c4d-c7cfe0ebc210
2,016
41,286
def swap_keys_values(): {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
59b507a0-b0a2-42b7-a6af-736ab71c8fe1
2,016
34,633
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
59b507a0-b0a2-42b7-a6af-736ab71c8fe1
2,016
35,033
def swap_keys_values(d): {v: k for k, v in 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
59b507a0-b0a2-42b7-a6af-736ab71c8fe1
2,016
27,166
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
59b507a0-b0a2-42b7-a6af-736ab71c8fe1
2,016
16,270
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
59b507a0-b0a2-42b7-a6af-736ab71c8fe1
2,016
9,694
def swap_unique_keys_values(d): for i in d: if d[i] in j: del j[d[i]] else: j[d[i]] = i return j
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
6668ebd6-a850-4666-b8cc-5c934a67601a
2,016
3,233
def swap_unique_keys_values(d): for i in d: if d[i] in j: del j[d[i]] else: j[d[i]] = i return j
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
6668ebd6-a850-4666-b8cc-5c934a67601a
2,016
12,663
def swap_unique_keys_values(d): for i in d: if d[i] in j: del j[d[i]] else: j[d[i]] = i return j
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
6668ebd6-a850-4666-b8cc-5c934a67601a
2,016
18,889
def swap_unique_keys_values(d): n_dict = {} double = set() for k, v in list(d.items()): if v in n_dict: double.add(v) n_dict[v] = k for k in double: del n_dict[k] return n_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
712c50ed-0c17-44f1-a863-183f2d9a5e14
2,016
9,399
def swap_unique_keys_values(d): n_dict = {} double = set() for k, v in list(d.items()): if v in n_dict: double.add(v) n_dict[v] = k for k in double: del n_dict[k] return n_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
712c50ed-0c17-44f1-a863-183f2d9a5e14
2,016
39,818
def swap_unique_keys_values(d): n_dict = {} double = set() for k, v in list(d.items()): if v in n_dict: double.add(v) n_dict[v] = k for k in double: del n_dict[k] return n_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
712c50ed-0c17-44f1-a863-183f2d9a5e14
2,016
8,138
def swap_keys_values(d): new_dictionary = {} for x in d: key = x value = d[x] new_dictionary[value] = key return new_dictionary
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
4986b17f-a671-4d40-a5ca-1c65fd498cbf
2,016
22,505
def swap_keys_values(d): new_dictionary = {} for x in d: key = x value = d[x] new_dictionary[value] = key return new_dictionary
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
4986b17f-a671-4d40-a5ca-1c65fd498cbf
2,016
24,919
def swap_unique_keys_values(d): new_dictionary = {} for x in d: key = x value = d[x] new_dictionary[value] = key new_dictionary.pop(7) return new_dictionary
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
4986b17f-a671-4d40-a5ca-1c65fd498cbf
2,016
12,379
def swap_unique_keys_values(d): new_dictionary = {} for x in d: key = x value = d[x] new_dictionary[value] = key new_dictionary.pop(7) return new_dictionary
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
4986b17f-a671-4d40-a5ca-1c65fd498cbf
2,016
38,828
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
bd03ecd6-cea3-4854-803a-b14d429489a7
2,016
35,931
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
bd03ecd6-cea3-4854-803a-b14d429489a7
2,016
21,319
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
bd03ecd6-cea3-4854-803a-b14d429489a7
2,016
18,626
def swap_unique_keys_values(d): d = {v: k for k, v in list(d.items())} return d
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
f463a026-5eb4-4a39-a858-3a798215a4ee
2,016
20,060
def swap_unique_keys_values(d): d = {v: k for k, v in list(d.items())} return d
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
f463a026-5eb4-4a39-a858-3a798215a4ee
2,016
13,041
def swap_unique_keys_values(d): d = {v: k for k, v in list(d.items())} return d
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
f463a026-5eb4-4a39-a858-3a798215a4ee
2,016
39,525
def swap_keys_values(d): swapped_dict = dict(list(zip(list(d.values()), list(d.keys())))) return swapped_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
f5dc8223-cf9e-429f-aae8-350d82da1982
2,016
37,485
def swap_keys_values(d): swapped_dict = dict(list(zip(list(d.values()), list(d.keys())))) return swapped_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
f5dc8223-cf9e-429f-aae8-350d82da1982
2,016
12,169
def swap_unique_keys_values(d): swapped_dict = dict(list(zip(list(d.values()), list(d.keys())))) return set(swapped_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
f5dc8223-cf9e-429f-aae8-350d82da1982
2,016
29,563
def swap_unique_keys_values(d): swapped_dict = set(dict(list(zip(list(d.values()), list(d.keys()))))) return swapped_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
f5dc8223-cf9e-429f-aae8-350d82da1982
2,016
25,878
def swap_unique_keys_values(d): swapped_dict = dict(list(zip(list(d.values()), list(d.keys())))) return set(swapped_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
f5dc8223-cf9e-429f-aae8-350d82da1982
2,016
20,903
def swap_unique_keys_values(d): swapped_dict = {v: k for k, v in list(d.items())} return swapped_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
f5dc8223-cf9e-429f-aae8-350d82da1982
2,016
35,757
def swap_unique_keys_values(d): swapped_dict = {v: k for k, v in list(d.items())} return set(swapped_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
f5dc8223-cf9e-429f-aae8-350d82da1982
2,016
447
def swap_keys_values(d): reversed_d = {(v, k) for k, v in d.items()} return reversed_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
99a8a900-efcf-4a9e-86ba-fdd0df4312d3
2,016
5,947
def swap_keys_values(d): reversed_d = dict((v, k) for k, v in d.items()) return reversed_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
99a8a900-efcf-4a9e-86ba-fdd0df4312d3
2,016
26,413
def swap_unique_keys_values(d): seen = list(d.keys()) swapped_dict = dict(list(zip(list(d.values()), list(d.keys())))) for v, k in swapped_dict: if k in seen: break return swapped_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
f5dc8223-cf9e-429f-aae8-350d82da1982
2,016
31,724
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
99a8a900-efcf-4a9e-86ba-fdd0df4312d3
2,016
31,252
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
99a8a900-efcf-4a9e-86ba-fdd0df4312d3
2,016
4,460
def swap_unique_keys_values(d): return {v: k for k, v in list(d.items()) if v in list(d.values())}
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
99a8a900-efcf-4a9e-86ba-fdd0df4312d3
2,016
18,577
def swap_unique_keys_values(d): return {v: k for k, v in list(d.items()) if v in list(d.values())}
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
99a8a900-efcf-4a9e-86ba-fdd0df4312d3
2,016
37,878
def swap_unique_keys_values(d): return {v: k for k, v in list(d.items()) if v in list(d.values())}
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
99a8a900-efcf-4a9e-86ba-fdd0df4312d3
2,016
31,328
def swap_unique_keys_values(d): seen = list(d.keys()) swapped_dict = dict(list(zip(list(d.values()), list(d.keys())))) print(list(swapped_dict.values())) return swapped_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
f5dc8223-cf9e-429f-aae8-350d82da1982
2,016
16,992
def swap_unique_keys_values(d): values = list(d.values()) unique = [x for x in values if values.count(x) == 1] swapped_dict = 0 if unique in values: swapped_dict = dict(list(zip(list(d.values()), list(d.keys())))) return swapped_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
f5dc8223-cf9e-429f-aae8-350d82da1982
2,016
31,682
def swap_unique_keys_values(d): values = list(d.values()) unique = [x for x in values if values.count(x) == 1] swapped_dict = 0 if unique in values: swapped_dict = {v: k for k, v in list(d.items())} return swapped_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
f5dc8223-cf9e-429f-aae8-350d82da1982
2,016
32,913
def swap_unique_keys_values(d): values = list(d.values()) unique = [x for x in values if values.count(x) == 1] swapped_dict = 0 if unique == True: swapped_dict = {v: k for k, v in list(d.items())} return swapped_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
f5dc8223-cf9e-429f-aae8-350d82da1982
2,016
29,552
def swap_unique_keys_values(d): values = list(d.values()) unique = [x for x in values if values.count(x) == 1] swapped_dict = 0 if unique == True: swapped_dict = {v: k for k, v in list(d.items())} return swapped_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
f5dc8223-cf9e-429f-aae8-350d82da1982
2,016
23,605
def swap_unique_keys_values(d): values = list(d.values()) unique = [x for x in values if values.count(x) == 1] swapped_dict = 0 if unique == True: swapped_dict = {v: k for k, v in list(d.items())} return swapped_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
f5dc8223-cf9e-429f-aae8-350d82da1982
2,016
14,667
def swap_keys_values(): {v: k for k, v in list(sys.argv[1].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
794362b7-cbcd-4bea-bafb-7967c266e248
2,016
37,994
def swap_keys_values(): {v: k for k, v in list(sys.argv[0].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
794362b7-cbcd-4bea-bafb-7967c266e248
2,016
26,911
def swap_unique_keys_values(d): c = {} e = [] r = {} seen = {} for value in list(d.values()): if value not in c: c[value] = 1 else: c[value] = c[value] + 1 for keys, values in list(c.items()): if values == 2: e.append(keys) del values for key in e: for value in list(d.items()): if key not in value: r[value[0]] = value[1] my_dict = r new_dict = {v: k for k, v in list(my_dict.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
7a72123c-6850-4e9f-b407-211283f04a4c
2,016
19,620
def swap_unique_keys_values(d): c = {} e = [] r = {} seen = {} for value in list(d.values()): if value not in c: c[value] = 1 else: c[value] = c[value] + 1 for keys, values in list(c.items()): if values == 2: e.append(keys) del values for key in e: for value in list(d.items()): if key not in value: r[value[0]] = value[1] my_dict = r new_dict = {v: k for k, v in list(my_dict.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
7a72123c-6850-4e9f-b407-211283f04a4c
2,016
995
def swap_unique_keys_values(d): c = {} e = [] r = {} seen = {} for value in list(d.values()): if value not in c: c[value] = 1 else: c[value] = c[value] + 1 for keys, values in list(c.items()): if values == 2: e.append(keys) del values for key in e: for value in list(d.items()): if key not in value: r[value[0]] = value[1] my_dict = r new_dict = {v: k for k, v in list(my_dict.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
7a72123c-6850-4e9f-b407-211283f04a4c
2,016
33,246
def swap_unique_keys_values(d): c = {} e = {} r = {} seen = {} for value in list(d.values()): if value not in c: c[value] = 1 else: c[value] += 1 for keys, values in list(c.items()): if values == 2: e.append(keys) del values for key in e: for value in list(d.items()): if key not in value: r[value[0]] = value[1] my_dict = r new_dict = {v: k for k, v in list(my_dict.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
f463a026-5eb4-4a39-a858-3a798215a4ee
2,016
13,411
def swap_keys_values(d): list(zip(list(d.values()), list(d.keys())))
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
262b3841-5158-4b0c-be99-57281e73f267
2,016
10,644
def swap_keys_values(d): return dict(list(zip(list(d.values()), list(d.keys()))))
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
262b3841-5158-4b0c-be99-57281e73f267
2,016
40,318
def swap_keys_values(d): l = Counter(list(d.values())) return {value: key for key, value in list(d.items()) if l[value] == 1}
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
262b3841-5158-4b0c-be99-57281e73f267
2,016
3,227
def swap_keys_values(d): l = Counter(list(d.values())) return {value: key for key, value in list(d.items()) if l[value] == 1}
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
262b3841-5158-4b0c-be99-57281e73f267
2,016
17,341
def swap_unique_keys_values(d): l = Counter(list(d.values())) return {value: key for key, value in list(d.items()) if l[value] == 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
262b3841-5158-4b0c-be99-57281e73f267
2,016
41,038
def swap_unique_keys_values(d): l = Counter(list(d.values())) return {value: key for key, value in list(d.items()) if l[value] == 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
262b3841-5158-4b0c-be99-57281e73f267
2,016
9,947
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
6cbd9686-8a3c-4d12-8a1a-70c661732027
2,016
5,220
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
6cbd9686-8a3c-4d12-8a1a-70c661732027
2,016
1,949
def swap_unique_keys_values(d): new_dict = {} for k in d: v = d.get(k) if v in new_dict: del new_dict[v] else: new_dict[v] = k 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'}
true
6cbd9686-8a3c-4d12-8a1a-70c661732027
2,016
3,174
def swap_unique_keys_values(d): new_dict = {} for k in d: v = d.get(k) if v in new_dict: del new_dict[v] else: new_dict[v] = k 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'}
true
6cbd9686-8a3c-4d12-8a1a-70c661732027
2,016
16,575
def swap_keys_values(a): for k, v in a.items: tmp = k k = v v = tmp return sorted(a)
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
a48376ed-7138-4481-a4da-74490838ea3e
2,016
11,408
def swap_keys_values(in_dict): out_dict = {} for t, v in list(in_dict.items()): out_dict[v] = t 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
11fcbbcf-716f-4e92-ab7c-407d4712c9e8
2,016
11,761
def swap_keys_values(in_dict): out_dict = {} for t, v in list(in_dict.items()): out_dict[v] = t 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
11fcbbcf-716f-4e92-ab7c-407d4712c9e8
2,016
33,796
def swap_keys_values(a): for k, v in list(a.items()): tmp = k k = v v = tmp return sorted(a)
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
a48376ed-7138-4481-a4da-74490838ea3e
2,016
4,498
def swap_keys_values(a): for k, v in list(a.items()): tmp = k k = v v = tmp print(a) return sorted(a)
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
a48376ed-7138-4481-a4da-74490838ea3e
2,016
26,976
def swap_unique_keys_values(d): new = {} for k in d: v = d.get(k) if v in new: del ne[v] else: new[v] = k return new
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
26,082
def swap_unique_keys_values(d): new = {} for k in d: v = d.get(k) if v in new: del new[v] else: new[v] = k return new
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
f1c26f39-fb4c-4010-aaa3-142fb52f57b9
2,016
26,190
def swap_unique_keys_values(d): new = {} for k in d: v = d.get(k) if v in new: del new[v] else: new[v] = k return new
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
f1c26f39-fb4c-4010-aaa3-142fb52f57b9
2,016
8,714
def swap_keys_values(a): for i in a: tmp = i i = a[i] a[i] = tmp return sorted(a)
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
a48376ed-7138-4481-a4da-74490838ea3e
2,016
26,041
def swap_keys_values(a): dir = {} for i in a: dir[a[i]] = i return sorted(dir)
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
a48376ed-7138-4481-a4da-74490838ea3e
2,016
26,525
def swap_keys_values(a): dir = {} for i in a: dir[a[i]] = i return dir
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
a48376ed-7138-4481-a4da-74490838ea3e
2,016
7,841
def swap_keys_values(a): dir = {} for i in a: dir[a[i]] = i return dir
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
a48376ed-7138-4481-a4da-74490838ea3e
2,016
30,805
def swap_unique_keys_values(a): lis = [] for no in list(a.items()): if a.count(no) > 1: lis.append(no) dir = {} for i in a: if dir[a[i]] not in lis: dir[a[i]] = i return dir
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
a48376ed-7138-4481-a4da-74490838ea3e
2,016
27,754
def swap_unique_keys_values(a): lis = [] for no in list(a.items()): if no.count(a) > 1: lis.append(no) dir = {} for i in a: if dir[a[i]] not in lis: dir[a[i]] = i return dir
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
a48376ed-7138-4481-a4da-74490838ea3e
2,016
26,699
def swap_unique_keys_values(a): lis = [] for no in list(a.items()): if no.count(a) > 1: lis.append(no) dir = {} for i in a: k = dir[a[i]] if k not in lis: dir[a[i]] = i return dir
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
a48376ed-7138-4481-a4da-74490838ea3e
2,016
21,171
def swap_unique_keys_values(a): lis = [] for no in list(a.items()): if no.count(a) > 1: lis.append(no) dir = {} for i in a: if a[i] not in lis: dir[a[i]] = i return dir
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
a48376ed-7138-4481-a4da-74490838ea3e
2,016
39,350
def swap_unique_keys_values(a): lis = [] for no in list(a.items()): if no.count(a) > 1: lis.append(no) print(lis) dir = {} for i in a: if a[i] not in lis: dir[a[i]] = i return dir
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
a48376ed-7138-4481-a4da-74490838ea3e
2,016
946
def swap_unique_keys_values(a): lis = [] for no in list(a.items()): print(no.count(a)) if no.count(a) > 1: lis.append(no) dir = {} for i in a: if a[i] not in lis: dir[a[i]] = i return dir
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
a48376ed-7138-4481-a4da-74490838ea3e
2,016
12,615
def swap_unique_keys_values(a): lis = [] for no in list(a.values()): print(no.count(a)) if no.count(a) > 1: lis.append(no) dir = {} for i in a: if a[i] not in lis: dir[a[i]] = i return dir
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
a48376ed-7138-4481-a4da-74490838ea3e
2,016
21,073
def swap_unique_keys_values(a): lis = [] for no in list(a.values()): if a.count(no) > 1: lis.append(no) dir = {} for i in a: if a[i] not in lis: dir[a[i]] = i return dir
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
a48376ed-7138-4481-a4da-74490838ea3e
2,016
12,010
def swap_unique_keys_values(a): lis = [] for no in list(a.values()): if int(no).count(a) > 1: lis.append(no) dir = {} for i in a: if a[i] not in lis: dir[a[i]] = i return dir
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
a48376ed-7138-4481-a4da-74490838ea3e
2,016
8,938
def swap_unique_keys_values(a): lis = [] for no in list(a.values()): if str(no).count(a) > 1: lis.append(no) dir = {} for i in a: if a[i] not in lis: dir[a[i]] = i return dir
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
a48376ed-7138-4481-a4da-74490838ea3e
2,016
18,278
def swap_unique_keys_values(a): lis = [] for no in list(a.values()): print(str(no).count(a)) if str(no).count(a) > 1: lis.append(no) dir = {} for i in a: if a[i] not in lis: dir[a[i]] = i return dir
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
a48376ed-7138-4481-a4da-74490838ea3e
2,016
13,179
def swap_unique_keys_values(a): lis = [] for no in list(a.values()): print(str(no).count(list(a.values()))) if str(no).count(list(a.values())) > 1: lis.append(no) dir = {} for i in a: if a[i] not in lis: dir[a[i]] = i return dir
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
a48376ed-7138-4481-a4da-74490838ea3e
2,016
17,953
def swap_unique_keys_values(a): lis = [] for no in list(a.values()): print(no.count(list(a.values()))) if no.count(list(a.values())) > 1: lis.append(no) dir = {} for i in a: if a[i] not in lis: dir[a[i]] = i return dir
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
a48376ed-7138-4481-a4da-74490838ea3e
2,016
15,240
def swap_unique_keys_values(a): lis = [] for no in list(a.values()): if no.count(list(a.values())) > 1: lis.append(no) dir = {} for i in a: if a[i] not in lis: dir[a[i]] = i return dir
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
a48376ed-7138-4481-a4da-74490838ea3e
2,016
37,032
def swap_unique_keys_values(a): lis = [] for no in list(a.values()): if list(a.values()).count(no) > 1: lis.append(no) dir = {} for i in a: if a[i] not in lis: dir[a[i]] = i return dir
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
a48376ed-7138-4481-a4da-74490838ea3e
2,016
9,695
def swap_unique_keys_values(a): lis = [] for no in list(a.values()): print(list(a.values()).count(no)) if list(a.values()).count(no) > 1: lis.append(no) dir = {} for i in a: if a[i] not in lis: dir[a[i]] = i return dir
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
a48376ed-7138-4481-a4da-74490838ea3e
2,016
16,858
def swap_unique_keys_values(a): lis = [] for no in list(a.values()): print(values) print(list(a.values()).count(no)) if list(a.values()).count(no) > 1: lis.append(no) dir = {} for i in a: if a[i] not in lis: dir[a[i]] = i return dir
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
a48376ed-7138-4481-a4da-74490838ea3e
2,016
35,380
def swap_unique_keys_values(a): lis = [] for no in list(a.values()): print(a.values) if list(a.values()).count(no) > 1: lis.append(no) dir = {} for i in a: if a[i] not in lis: dir[a[i]] = i return dir
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
a48376ed-7138-4481-a4da-74490838ea3e
2,016
16,215
def swap_keys_values(d): d1 = {v: k for k, v in list(d.items())} print(d1)
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
29883390-7aa0-4484-9f1e-6fd0c1c8c420
2,016
7,472
def swap_unique_keys_values(a): lis = [] for no in list(a.values()): print(list(a.values())) if list(a.values()).count(no) > 1: lis.append(no) dir = {} for i in a: if a[i] not in lis: dir[a[i]] = i return dir
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
a48376ed-7138-4481-a4da-74490838ea3e
2,016
9,973
def swap_unique_keys_values(a): lis = [] val = list(a.values()) for no in val: if val.count(no) > 1: lis.append(no) dir = {} for i in a: if a[i] not in lis: dir[a[i]] = i return dir
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
a48376ed-7138-4481-a4da-74490838ea3e
2,016
23,736
def swap_unique_keys_values(a): lis = [] val = list(a.values()) for no in val: print(val) if val.count(no) > 1: lis.append(no) dir = {} for i in a: if a[i] not in lis: dir[a[i]] = i return dir
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
a48376ed-7138-4481-a4da-74490838ea3e
2,016
28,795
def swap_unique_keys_values(a): lis = [] val = list(a.values()) for no in val: print(lis(val)) if val.count(no) > 1: lis.append(no) dir = {} for i in a: if a[i] not in lis: dir[a[i]] = i return dir
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
a48376ed-7138-4481-a4da-74490838ea3e
2,016
10,098
def swap_keys_values(d): d1 = {v: k for k, v in list(d.items())} print(list(d1.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
29883390-7aa0-4484-9f1e-6fd0c1c8c420
2,016
507
def swap_keys_values(d): new_dict = {} for k in d: new_dict[d[k]] = k 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
030c2a56-757a-4b4d-ac91-67aecc3d9b33
2,016