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
|
---|---|---|---|---|---|---|---|---|
39,650 |
def swap_keys_values(d):
d = dict((v, k) for k, v in list(d.items()))
d = SortedDict(d)
print(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 |
1a650795-f8bf-47db-90f0-c896555da6d7
| 2,016 |
32,357 |
def swap_keys_values(d):
d = dict((v, k) for k, v in list(d.items()))
print(sorted(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 |
1a650795-f8bf-47db-90f0-c896555da6d7
| 2,016 |
3,955 |
def swap_keys_values(d):
d = dict((v, k) for k, v in list(d.items()))
print(sorted(list(d.items()), key=sorter))
|
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 |
1a650795-f8bf-47db-90f0-c896555da6d7
| 2,016 |
4,150 |
def swap_unique_keys_values(d):
a = [v for k, v in list(d.items())]
for i in a:
if a.count(i) == 1:
a.pop(i)
e = {}
for k, v in list(d.items()):
if v not in a:
e[v] = k
return e
|
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 |
15c8870d-4f5a-4578-b0fb-4dd4a4402626
| 2,016 |
7,236 |
def swap_keys_values(d):
d = dict((v, k) for k, v in list(d.items()))
print(sorted(list(d.items()), key=sorter))
|
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 |
1a650795-f8bf-47db-90f0-c896555da6d7
| 2,016 |
7,932 |
def swap_keys_values(d):
d = dict((v, k) for k, v in list(d.items()))
print(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 |
1a650795-f8bf-47db-90f0-c896555da6d7
| 2,016 |
30,785 |
def swap_unique_keys_values(d):
a = [v for k, v in list(d.items())]
for i in a:
if a.count(i) == 1:
a.remove(i)
e = {}
for k, v in list(d.items()):
if v not in a:
e[v] = k
return e
|
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 |
15c8870d-4f5a-4578-b0fb-4dd4a4402626
| 2,016 |
42,001 |
def swap_keys_values(d):
d = dict((v, k) for k, v in list(d.items()))
d = list(d.items())
print(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 |
1a650795-f8bf-47db-90f0-c896555da6d7
| 2,016 |
31,985 |
def swap_keys_values(d):
d = dict((v, k) for k, v in list(d.items()))
print(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 |
1a650795-f8bf-47db-90f0-c896555da6d7
| 2,016 |
34,654 |
def swap_keys_values(d):
d = dict((v, k) for k, v in list(d.items()))
print([k for k, v in sorted(list(d.items()), key=lambda x: x[1],
reverse=True)])
|
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 |
1a650795-f8bf-47db-90f0-c896555da6d7
| 2,016 |
19,677 |
def swap_keys_values(d):
d = dict((v, k) for k, v in list(d.items()))
print([k for k, v in sorted(list(d.items()), key=lambda x: x[1],
reverse=True)])
|
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 |
1a650795-f8bf-47db-90f0-c896555da6d7
| 2,016 |
13,987 |
def swap_keys_values(d):
d = dict((v, k) for k, v in list(d.items()))
print([k for k, v in sorted(list(d.items()), key=lambda x: x[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 |
1a650795-f8bf-47db-90f0-c896555da6d7
| 2,016 |
13,698 |
def swap_keys_values(d):
d = dict((v, k) for k, v in list(d.items()))
print(sorted(list(d.items()), key=lambda x: x[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 |
1a650795-f8bf-47db-90f0-c896555da6d7
| 2,016 |
6,366 |
def swap_keys_values(d):
d = dict((v, k) for k, v in list(d.items()))
print([(k, v) for k, v in sorted(list(d.items()), key=lambda x: x[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 |
1a650795-f8bf-47db-90f0-c896555da6d7
| 2,016 |
28,040 |
def swap_keys_values(d):
d = dict((v, k) for k, v in list(d.items()))
sd = sorted(d.items())
print(sd)
|
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 |
1a650795-f8bf-47db-90f0-c896555da6d7
| 2,016 |
416 |
def swap_keys_values(d):
d = dict((v, k) for k, v in list(d.items()))
print(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 |
1a650795-f8bf-47db-90f0-c896555da6d7
| 2,016 |
13,730 |
def swap_keys_values(d):
d = dict((v, k) for k, v in list(d.items()))
print(sorted(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 |
1a650795-f8bf-47db-90f0-c896555da6d7
| 2,016 |
35,588 |
def swap_keys_values(d):
d = dict((v, k) for k, v in list(d.items()))
d = sorted(d)
print(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 |
1a650795-f8bf-47db-90f0-c896555da6d7
| 2,016 |
30,891 |
def swap_keys_values(d):
d = dict((v, k) for k, v in list(d.items()))
d = sorted(list(d.items()), key=lambda t: t[0])
print(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 |
1a650795-f8bf-47db-90f0-c896555da6d7
| 2,016 |
9,132 |
def swap_keys_values(d):
d = dict((v, k) for k, v in list(d.items()))
new_dict = sorted(list(d.items()), key=lambda t: t[0])
print(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'}
| false |
1a650795-f8bf-47db-90f0-c896555da6d7
| 2,016 |
21,778 |
def swap_keys_values(d):
d = dict((v, k) for k, v in list(d.items()))
new_dict = sorted(list(d.items()), key=lambda t: t[0])
print(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'}
| false |
1a650795-f8bf-47db-90f0-c896555da6d7
| 2,016 |
30,246 |
def swap_keys_values(d):
d = dict((v, k) for k, v in list(d.items()))
new_dict = sorted(list(d.items()), key=lambda t: t[0])
print(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'}
| false |
1a650795-f8bf-47db-90f0-c896555da6d7
| 2,016 |
41,659 |
def swap_keys_values(d):
d = dict((v, k) for k, v in list(d.items()))
new_dict = sorted(list(d.items()), key=lambda t: t[0])
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'}
| false |
1a650795-f8bf-47db-90f0-c896555da6d7
| 2,016 |
12,167 |
def swap_keys_values(d):
d = dict((v, k) for k, v in list(d.items()))
new_dict = sorted(list(d.items()), key=lambda t: t[0])
print(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'}
| false |
1a650795-f8bf-47db-90f0-c896555da6d7
| 2,016 |
28,568 |
def swap_keys_values(d):
d = dict((v, k) for k, v in list(d.items()))
print(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'}
| false |
1a650795-f8bf-47db-90f0-c896555da6d7
| 2,016 |
17,581 |
def swap_keys_values(d):
d = dict((v, k) for k, v in list(d.items()))
print(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 |
1a650795-f8bf-47db-90f0-c896555da6d7
| 2,016 |
15,842 |
def swap_keys_values(d):
d = dict((v, k) for k, v in list(d.items()))
print(sorted(list(d.items()), key=lambda t: t[0]))
|
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 |
1a650795-f8bf-47db-90f0-c896555da6d7
| 2,016 |
17,623 |
def swap_keys_values(d):
d = 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 |
1a650795-f8bf-47db-90f0-c896555da6d7
| 2,016 |
38,590 |
def swap_keys_values(d):
new_dict = 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 |
1a650795-f8bf-47db-90f0-c896555da6d7
| 2,016 |
30,444 |
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 |
1a650795-f8bf-47db-90f0-c896555da6d7
| 2,016 |
8,251 |
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 |
1a650795-f8bf-47db-90f0-c896555da6d7
| 2,016 |
10,799 |
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 |
1a650795-f8bf-47db-90f0-c896555da6d7
| 2,016 |
33,084 |
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 |
f69c7616-4d20-4dbe-b3f8-0d10db7adfe4
| 2,016 |
4,112 |
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 |
f69c7616-4d20-4dbe-b3f8-0d10db7adfe4
| 2,016 |
22,370 |
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 |
f69c7616-4d20-4dbe-b3f8-0d10db7adfe4
| 2,016 |
31,244 |
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 |
f69c7616-4d20-4dbe-b3f8-0d10db7adfe4
| 2,016 |
2,431 |
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 |
f69c7616-4d20-4dbe-b3f8-0d10db7adfe4
| 2,016 |
19,587 |
def swap_unique_keys_values(d):
a = [v for k, v in list(d.items())]
for i in a:
if 1 < a.count(i):
a.remove(i)
e = {}
for k, v in list(d.items()):
if v in a:
e[v] = k
return e
|
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 |
15c8870d-4f5a-4578-b0fb-4dd4a4402626
| 2,016 |
31,150 |
def swap_keys_values(d):
new_d = d((v, k) for k, v in list(d.items()))
return new_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 |
3a86cbea-7925-4e8e-9baa-3505dd2219c7
| 2,016 |
26,360 |
def swap_keys_values(d):
new_d = d((v, k) for k, v in list(d.items()))
return new_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 |
3a86cbea-7925-4e8e-9baa-3505dd2219c7
| 2,016 |
24,817 |
def swap_keys_values(d):
new_d = d((v, k) for k, v in list(d.items()))
return new_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 |
3a86cbea-7925-4e8e-9baa-3505dd2219c7
| 2,016 |
30,059 |
def swap_unique_keys_values(d):
a = [v for k, v in list(d.items())]
for i in a:
if 1 < a.count(i):
a = [j for j in a if j != i]
e = {}
for k, v in list(d.items()):
if v in a:
e[v] = k
return e
|
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 |
15c8870d-4f5a-4578-b0fb-4dd4a4402626
| 2,016 |
24,384 |
def swap_unique_keys_values(d):
a = [v for k, v in list(d.items())]
for i in a:
if 1 < a.count(i):
a = [j for j in a if j != i]
e = {}
for k, v in list(d.items()):
if v in a:
e[v] = k
return e
|
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 |
15c8870d-4f5a-4578-b0fb-4dd4a4402626
| 2,016 |
12,227 |
def swap_unique_keys_values(d):
a = [v for k, v in list(d.items())]
for i in a:
if 1 < a.count(i):
a = [j for j in a if j != i]
e = {}
for k, v in list(d.items()):
if v in a:
e[v] = k
return e
|
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 |
15c8870d-4f5a-4578-b0fb-4dd4a4402626
| 2,016 |
23,823 |
def swap_unique_keys_values(d):
new_dict = dict((v, k) for k, v in list(d.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 |
1a650795-f8bf-47db-90f0-c896555da6d7
| 2,016 |
8,743 |
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 |
4788f2f7-8b97-41a8-88ee-697183f85246
| 2,016 |
35,510 |
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 |
4788f2f7-8b97-41a8-88ee-697183f85246
| 2,016 |
12,075 |
def swap_unique_keys_values(d):
keys = [k for k in list(d.keys())]
vals = [v for v in list(d.values())]
dd = {}
for i in range(0, len(vals)):
if vals.count(vals[i]) == 1:
dd[vals[i]] = keys[i]
return dd
|
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 |
4788f2f7-8b97-41a8-88ee-697183f85246
| 2,016 |
2,874 |
def swap_unique_keys_values(d):
keys = [k for k in list(d.keys())]
vals = [v for v in list(d.values())]
dd = {}
for i in range(0, len(vals)):
if vals.count(vals[i]) == 1:
dd[vals[i]] = keys[i]
return dd
|
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 |
4788f2f7-8b97-41a8-88ee-697183f85246
| 2,016 |
18,932 |
def swap_unique_keys_values(d):
new_dict = dict((v, k) for k, v in list(d.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 |
1a650795-f8bf-47db-90f0-c896555da6d7
| 2,016 |
12,962 |
def swap_unique_keys_values(d):
new_dict = dict((v, k) for k, v in list(d.items()))
new_dict.pop(7, None)
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 |
1a650795-f8bf-47db-90f0-c896555da6d7
| 2,016 |
29,233 |
def swap_unique_keys_values(d):
new_dict = dict((v, k) for k, v in list(d.items()))
new_dict.pop(7, None)
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 |
1a650795-f8bf-47db-90f0-c896555da6d7
| 2,016 |
39,367 |
def swap_unique_keys_values(d):
new_dict = dict((v, k) for k, v in list(d.items()))
new_dict.pop(7, None)
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 |
1a650795-f8bf-47db-90f0-c896555da6d7
| 2,016 |
6,172 |
def swap_keys_values(d):
new_dict = dict((k, v) 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'}
| false |
7b8e2d7b-1f3a-4e34-b02c-e6ac46baa465
| 2,016 |
7,577 |
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 |
7b8e2d7b-1f3a-4e34-b02c-e6ac46baa465
| 2,016 |
13,062 |
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 |
7b8e2d7b-1f3a-4e34-b02c-e6ac46baa465
| 2,016 |
3,576 |
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 |
7b8e2d7b-1f3a-4e34-b02c-e6ac46baa465
| 2,016 |
3,133 |
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 |
7b8e2d7b-1f3a-4e34-b02c-e6ac46baa465
| 2,016 |
23,363 |
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 |
fccb16a1-abd7-4ee8-a2c6-5b7653d7a7dc
| 2,016 |
28,910 |
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 |
fccb16a1-abd7-4ee8-a2c6-5b7653d7a7dc
| 2,016 |
17,538 |
def swap_keys_values(my_dict):
new_dict = {}
new_dict = {v: k for k, v in list(my_dict.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 |
7f7b8266-dd5b-41e4-86a0-07e112b10147
| 2,016 |
15,592 |
def swap_keys_values(my_dict):
new_dict = {}
new_dict = {v: k for k, v in list(my_dict.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 |
7f7b8266-dd5b-41e4-86a0-07e112b10147
| 2,016 |
39,914 |
def swap_keys_values(my_dict):
new_dict = {}
new_dict = {v: k for k, v in list(my_dict.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 |
7f7b8266-dd5b-41e4-86a0-07e112b10147
| 2,016 |
27,133 |
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 |
fccb16a1-abd7-4ee8-a2c6-5b7653d7a7dc
| 2,016 |
15,402 |
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 |
fccb16a1-abd7-4ee8-a2c6-5b7653d7a7dc
| 2,016 |
26,747 |
def swap_keys_values(my_dict):
new_dict = {}
new_dict = {v: k for k, v in list(my_dict.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 |
88e97329-9c3f-4e1a-8643-1311f4e801a9
| 2,016 |
31,572 |
def swap_keys_values(my_dict):
new_dict = {}
new_dict = {v: k for k, v in list(my_dict.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 |
88e97329-9c3f-4e1a-8643-1311f4e801a9
| 2,016 |
40,925 |
def swap_keys_values(d):
for c in d:
tmp == d[key]
d[key] == value
value == tmp
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 |
5a6b9af4-c978-4326-ba5b-405c4a284f15
| 2,016 |
14,411 |
def swap_keys_values(d):
tmp = ''
for c in d:
tmp = d[key]
d[key] = value
value = tmp
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 |
5a6b9af4-c978-4326-ba5b-405c4a284f15
| 2,016 |
13,864 |
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 |
daaef1e8-1fe4-4dc4-b002-6e89fad22a66
| 2,016 |
33,650 |
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 |
daaef1e8-1fe4-4dc4-b002-6e89fad22a66
| 2,016 |
28,079 |
def swap_unique_keys_values(d):
keys = [k for k in list(d.keys())]
vals = [v for v in list(d.values())]
dd = {}
for i in range(0, len(vals)):
if vals.count(vals[i]) == 1:
dd[vals[i]] = keys[i]
return dd
|
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 |
daaef1e8-1fe4-4dc4-b002-6e89fad22a66
| 2,016 |
27,314 |
def swap_unique_keys_values(d):
keys = [k for k in list(d.keys())]
vals = [v for v in list(d.values())]
dd = {}
for i in range(0, len(vals)):
if vals.count(vals[i]) == 1:
dd[vals[i]] = keys[i]
return dd
|
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 |
daaef1e8-1fe4-4dc4-b002-6e89fad22a66
| 2,016 |
31,118 |
def swap_unique_keys_values(d):
keys = [k for k in list(d.keys())]
vals = [v for v in list(d.values())]
dd = {}
for i in range(0, len(vals)):
if vals.count(vals[i]) == 1:
dd[vals[i]] = keys[i]
return dd
|
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 |
daaef1e8-1fe4-4dc4-b002-6e89fad22a66
| 2,016 |
38,398 |
def swap_keys_values(d):
new_dict = dict([(v, k) for k, v in list(d.items())])
return new_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 |
a2b86688-0a82-4779-8335-a584906257b0
| 2,016 |
18,570 |
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 |
a2b86688-0a82-4779-8335-a584906257b0
| 2,016 |
1,757 |
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 |
a2b86688-0a82-4779-8335-a584906257b0
| 2,016 |
41,188 |
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 |
f5dc8223-cf9e-429f-aae8-350d82da1982
| 2,016 |
34,617 |
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 |
f5dc8223-cf9e-429f-aae8-350d82da1982
| 2,016 |
38,000 |
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 |
f5dc8223-cf9e-429f-aae8-350d82da1982
| 2,016 |
271 |
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 |
f5dc8223-cf9e-429f-aae8-350d82da1982
| 2,016 |
27,771 |
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 |
f5dc8223-cf9e-429f-aae8-350d82da1982
| 2,016 |
14,871 |
def swap_unique_keys_values(d):
new_dict = {}
for k in d:
v = d[k]
if v not in new_dict:
new_dict[v] = k
else:
del new_dict[v]
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 |
a2b86688-0a82-4779-8335-a584906257b0
| 2,016 |
13 |
def swap_unique_keys_values(d):
new_dict = {}
for k in d:
v = d[k]
if v not in new_dict:
new_dict[v] = k
else:
del new_dict[v]
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 |
a2b86688-0a82-4779-8335-a584906257b0
| 2,016 |
11,580 |
def swap_unique_keys_values(d):
new_dict = {}
for k in d:
v = d[k]
if v not in new_dict:
new_dict[v] = k
else:
del new_dict[v]
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 |
a2b86688-0a82-4779-8335-a584906257b0
| 2,016 |
3,132 |
def swap_keys_values(d):
swapped = {}
for k, v in list(d.items()):
swapped[v] = k
return swapped
|
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 |
109505d5-be18-4a61-8318-5d522de4300e
| 2,016 |
37,115 |
def swap_keys_values(d):
swapped = {}
for k, v in list(d.items()):
swapped[v] = k
return swapped
|
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 |
109505d5-be18-4a61-8318-5d522de4300e
| 2,016 |
14,853 |
def swap_keys_values(d):
swapped = {}
for k, v in list(d.items()):
swapped[v] = k
return swapped
|
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 |
109505d5-be18-4a61-8318-5d522de4300e
| 2,016 |
19,893 |
def swap_unique_keys_values(d):
a = [v for k, v in 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'}
| false |
5a6b9af4-c978-4326-ba5b-405c4a284f15
| 2,016 |
33,952 |
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 |
5a6b9af4-c978-4326-ba5b-405c4a284f15
| 2,016 |
12,977 |
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 |
5a6b9af4-c978-4326-ba5b-405c4a284f15
| 2,016 |
18,642 |
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 |
8d8fa15f-3f0d-4a69-849b-9b7da96123cd
| 2,016 |
31,617 |
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 |
8d8fa15f-3f0d-4a69-849b-9b7da96123cd
| 2,016 |
3,140 |
def swap_keys_values():
a = [v for k, v in list(d.items())]
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 |
5a6b9af4-c978-4326-ba5b-405c4a284f15
| 2,016 |
40,608 |
def swap_keys_values(d):
a = [v for k, v in list(d.items())]
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 |
5a6b9af4-c978-4326-ba5b-405c4a284f15
| 2,016 |
26,486 |
def swap_keys_values(d):
a = [v for k, v in list(d.items())]
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 |
5a6b9af4-c978-4326-ba5b-405c4a284f15
| 2,016 |
26,313 |
def swap_unique_keys_values(d):
n_d = {}
dup = []
for k in d:
if k in n_d:
dup.append(k)
n_d[d[k]] = k
for d in dup:
n_d.pop(d)
return n_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 |
420bf3b7-f5e7-4d7a-9cbb-fd46a8b4e956
| 2,016 |
42,391 |
def swap_unique_keys_values(d):
print(d)
n_d = {}
dup = []
for k in d:
if k in n_d:
dup.append(k)
n_d[d[k]] = k
print(dup)
for d in dup:
n_d.pop(d)
return n_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 |
420bf3b7-f5e7-4d7a-9cbb-fd46a8b4e956
| 2,016 |
37,241 |
def swap_unique_keys_values(d):
print(d)
n_d = {}
dup = []
for k in d:
if k in n_d:
dup.append(k)
n_d[d[k]] = k
print(dup)
for d in dup:
n_d.pop(d)
return n_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 |
420bf3b7-f5e7-4d7a-9cbb-fd46a8b4e956
| 2,016 |
2,475 |
def swap_unique_keys_values(d):
print(d)
n_d = {}
dup = []
for k in d:
if d[k] in n_d:
dup.append(k)
n_d[d[k]] = k
print(dup)
for x in dup:
n_d.pop(x)
return n_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 |
420bf3b7-f5e7-4d7a-9cbb-fd46a8b4e956
| 2,016 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.