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
|
---|---|---|---|---|---|---|---|---|
13,165 |
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 |
caddc359-e5b0-41d8-94ab-df712d5ea9ce
| 2,016 |
11,547 |
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 |
caddc359-e5b0-41d8-94ab-df712d5ea9ce
| 2,016 |
14,271 |
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 |
caddc359-e5b0-41d8-94ab-df712d5ea9ce
| 2,016 |
5,536 |
def swap_unique_keys_values(swap_me):
if swap_me is not None:
return {swap_me[key]: key for key in list(swap_me.keys()) if list(
swap_me.values()).count(swap_me[key]) == 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 |
d566071f-0679-42ce-9081-3fac29a67d21
| 2,016 |
9,261 |
def swap_unique_keys_values(swap_me):
if swap_me is not None:
return {swap_me[key]: key for key in list(swap_me.keys()) if list(
swap_me.values()).count(swap_me[key]) == 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 |
d566071f-0679-42ce-9081-3fac29a67d21
| 2,016 |
31,839 |
def swap_unique_keys_values(d):
tempd = {}
alltupps = []
newlist = []
for k, v in list(d.items()):
alltupps.append((v, k))
alltupps = sorted(alltupps)
i = 0
while i < len(alltupps) - 1:
if alltupps[i][0] != alltupps[i + 1][0]:
newlist.append(alltupps[i])
else:
i += 1
i += 1
if alltupps[-2][0] != alltupps[-1][0]:
newlist.append(alltupps[-1])
return dict(newlist)
|
swap_unique_keys_values
|
swap_unique_keys_values
|
Swap the keys of a dictionary with its unique values.
|
assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'}
| false |
9550e418-a019-49c2-a2e9-8322a300fb6f
| 2,016 |
15,443 |
def swap_unique_keys_values(d):
tempd = {}
alltupps = []
newlist = []
for k, v in list(d.items()):
alltupps.append((v, k))
alltupps = sorted(alltupps)
i = 0
while i < len(alltupps) - 1:
if alltupps[i][0] != alltupps[i + 1][0]:
newlist.append(alltupps[i])
else:
i += 1
i += 1
if alltupps[-2][0] != alltupps[-1][0]:
newlist.append(alltupps[-1])
return dict(newlist)
|
swap_unique_keys_values
|
swap_unique_keys_values
|
Swap the keys of a dictionary with its unique values.
|
assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'}
| false |
9550e418-a019-49c2-a2e9-8322a300fb6f
| 2,016 |
31,608 |
def swap_keys_values(x):
new_d = dict((v, k) for k, v in list(x.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'}
| true |
93426de2-87e4-4c00-9910-de51627bd576
| 2,016 |
9,309 |
def swap_keys_values(x):
new_d = dict((v, k) for k, v in list(x.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'}
| true |
93426de2-87e4-4c00-9910-de51627bd576
| 2,016 |
39,705 |
def swap_unique_keys_values(d):
store = {}
value = []
va = list(d.values())
for i in va:
value.append(i)
for k, v in list(d.items()):
if value.count(v) == 1:
store[k] = v
return {v: k for k, v in list(store.items())}
|
swap_unique_keys_values
|
swap_unique_keys_values
|
Swap the keys of a dictionary with its unique values.
|
assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'}
| true |
2f34a0ed-0d6a-447e-8e47-6a90f11d53a7
| 2,016 |
32,152 |
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 |
2f34a0ed-0d6a-447e-8e47-6a90f11d53a7
| 2,016 |
6,906 |
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 |
2f34a0ed-0d6a-447e-8e47-6a90f11d53a7
| 2,016 |
37,349 |
def swap_unique_keys_values(d):
store = {}
value = []
va = list(d.values())
for i in va:
value.append(i)
for k, v in list(d.items()):
if value.count(v) == 1:
store[k] = v
return {v: k for k, v in list(store.items())}
|
swap_unique_keys_values
|
swap_unique_keys_values
|
Swap the keys of a dictionary with its unique values.
|
assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'}
| true |
2f34a0ed-0d6a-447e-8e47-6a90f11d53a7
| 2,016 |
26,337 |
def swap_unique_keys_values(d):
store = {}
value = []
va = list(d.values())
for i in va:
value.append(i)
for k, v in list(d.items()):
if value.count(v) == 1:
store[k] = v
return {v: k for k, v in list(store.items())}
|
swap_unique_keys_values
|
swap_unique_keys_values
|
Swap the keys of a dictionary with its unique values.
|
assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'}
| true |
2f34a0ed-0d6a-447e-8e47-6a90f11d53a7
| 2,016 |
4,548 |
def swap_unique_keys_values(d):
store = {}
value = []
va = list(d.values())
for i in va:
value.append(i)
for k, v in list(d.items()):
if value.count(v) == 1:
store[k] = v
return {v: k for k, v in list(store.items())}
|
swap_unique_keys_values
|
swap_unique_keys_values
|
Swap the keys of a dictionary with its unique values.
|
assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'}
| true |
2f34a0ed-0d6a-447e-8e47-6a90f11d53a7
| 2,016 |
26,513 |
def swap_unique_keys_values(d):
return dict([(v, k) for k, v in list(d.items()) if list(d.values()).
count(v) == 1])
|
swap_unique_keys_values
|
swap_unique_keys_values
|
Swap the keys of a dictionary with its unique values.
|
assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'}
| true |
93426de2-87e4-4c00-9910-de51627bd576
| 2,016 |
36,714 |
def swap_unique_keys_values(d):
return dict([(v, k) for k, v in list(d.items()) if list(d.values()).
count(v) == 1])
|
swap_unique_keys_values
|
swap_unique_keys_values
|
Swap the keys of a dictionary with its unique values.
|
assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'}
| true |
93426de2-87e4-4c00-9910-de51627bd576
| 2,016 |
477 |
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 |
48db4273-a21e-41be-bca6-9b6444a15cbf
| 2,016 |
17,636 |
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 |
48db4273-a21e-41be-bca6-9b6444a15cbf
| 2,016 |
26,298 |
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[keys[i]] = vals[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'}
| false |
caddc359-e5b0-41d8-94ab-df712d5ea9ce
| 2,016 |
11,621 |
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 |
caddc359-e5b0-41d8-94ab-df712d5ea9ce
| 2,016 |
15,014 |
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 |
caddc359-e5b0-41d8-94ab-df712d5ea9ce
| 2,016 |
4,629 |
def swap_unique_keys_values(d):
store = {}
value = []
va = list(d.values())
for i in va:
value.append(i)
for k, v in list(d.items()):
if value.count(v) == 1:
store[k] = v
return {v: k for k, v in list(store.items())}
|
swap_unique_keys_values
|
swap_unique_keys_values
|
Swap the keys of a dictionary with its unique values.
|
assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'}
| true |
48db4273-a21e-41be-bca6-9b6444a15cbf
| 2,016 |
29,199 |
def swap_unique_keys_values(d):
store = {}
value = []
va = list(d.values())
for i in va:
value.append(i)
for k, v in list(d.items()):
if value.count(v) == 1:
store[k] = v
return {v: k for k, v in list(store.items())}
|
swap_unique_keys_values
|
swap_unique_keys_values
|
Swap the keys of a dictionary with its unique values.
|
assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'}
| true |
48db4273-a21e-41be-bca6-9b6444a15cbf
| 2,016 |
40,628 |
def swap_unique_keys_values(d):
store = {}
value = []
va = list(d.values())
for i in va:
value.append(i)
for k, v in list(d.items()):
if value.count(v) == 1:
store[k] = v
return {v: k for k, v in list(store.items())}
|
swap_unique_keys_values
|
swap_unique_keys_values
|
Swap the keys of a dictionary with its unique values.
|
assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'}
| true |
48db4273-a21e-41be-bca6-9b6444a15cbf
| 2,016 |
23,537 |
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 |
427cdab9-477f-4fb3-92b0-bf5eef785c90
| 2,016 |
32,907 |
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 |
427cdab9-477f-4fb3-92b0-bf5eef785c90
| 2,016 |
12,317 |
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 |
427cdab9-477f-4fb3-92b0-bf5eef785c90
| 2,016 |
23,761 |
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 |
427cdab9-477f-4fb3-92b0-bf5eef785c90
| 2,016 |
26,551 |
def swap_unique_keys_values(d):
new_dict = {}
values = []
keys = []
for z, q in list(d.items()):
keys.append(q)
values.append(z)
for z, q in list(d.items()):
if not keys.count(q) > 1:
new_dict[q] = z
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 |
6ae36e81-5a79-4a87-a484-a86635591a14
| 2,016 |
4,808 |
def swap_unique_keys_values(d):
new_dict = {}
values = []
keys = []
for z, q in list(d.items()):
keys.append(q)
values.append(z)
for z, q in list(d.items()):
if not keys.count(q) > 1:
new_dict[q] = z
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 |
6ae36e81-5a79-4a87-a484-a86635591a14
| 2,016 |
39,293 |
def swap_unique_keys_values(d):
new_dict = {}
values = []
keys = []
for z, q in list(d.items()):
keys.append(q)
values.append(z)
for z, q in list(d.items()):
if not keys.count(q) > 1:
new_dict[q] = z
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 |
0f49aa06-8917-4312-903b-8a4431682b21
| 2,016 |
22,369 |
def swap_unique_keys_values(d):
new_dict = {}
values = []
keys = []
for z, q in list(d.items()):
keys.append(q)
values.append(z)
for z, q in list(d.items()):
if not keys.count(q) > 1:
new_dict[q] = z
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 |
0f49aa06-8917-4312-903b-8a4431682b21
| 2,016 |
34,832 |
def swap_keys_values(d):
new_dict = {}
for z, q in list(d.items()):
new_dict[q] = z
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 |
0f49aa06-8917-4312-903b-8a4431682b21
| 2,016 |
5,912 |
def swap_keys_values(d):
new_dict = {}
for z, q in list(d.items()):
new_dict[q] = z
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 |
0f49aa06-8917-4312-903b-8a4431682b21
| 2,016 |
22,474 |
def swap_unique_keys_values(a):
value = list(a.values())
keys = list(a.keys())
dir = {}
for i in a:
if values.count(value[i]) < 2:
dir[value[i]] = keys[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 |
1,847 |
def swap_unique_keys_values(a):
value = list(a.values())
keys = list(a.keys())
dir = {}
for i in a:
if value.count(value[i]) < 2:
dir[value[i]] = keys[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 |
9,022 |
def swap_unique_keys_values(a):
value = list(a.values())
keys = list(a.keys())
dir = {}
for i in range(0, len(vaules)):
if value.count(value[i]) < 2:
dir[value[i]] = keys[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 |
31,877 |
def swap_unique_keys_values(a):
value = list(a.values())
keys = list(a.keys())
dir = {}
for i in range(0, len(value)):
if value.count(value[i]) < 2:
dir[value[i]] = keys[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 |
32,595 |
def swap_unique_keys_values(a):
value = list(a.values())
keys = list(a.keys())
dir = {}
for i in range(0, len(value)):
if value.count(value[i]) < 2:
dir[value[i]] = keys[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 |
5,967 |
def swap_unique_keys_values(a):
value = list(a.values())
keys = list(a.keys())
dir = {}
for i in range(0, len(value)):
if value.count(value[i]) < 2:
dir[value[i]] = keys[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 |
33,842 |
def swap_keys_values(d):
new_d = {}
for key, val in d:
new_d[val] = key
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 |
9675c8b9-337a-4fd1-bb8f-8e3510c7f703
| 2,016 |
37,838 |
def swap_keys_values(d):
new_d = {}
for key, val in d.items:
new_d[val] = key
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 |
9675c8b9-337a-4fd1-bb8f-8e3510c7f703
| 2,016 |
8,982 |
def swap_keys_values(d):
new_d = {}
for key, val in list(d.items()):
new_d[val] = key
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'}
| true |
9675c8b9-337a-4fd1-bb8f-8e3510c7f703
| 2,016 |
28,850 |
def swap_keys_values(d):
new_d = {}
for key, val in list(d.items()):
new_d[val] = key
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'}
| true |
9675c8b9-337a-4fd1-bb8f-8e3510c7f703
| 2,016 |
41,965 |
def swap_unique_keys_values(d):
new_d = {}
dups = []
for key, val in list(d.items()):
if val not in dups:
new_d[val] = key
dups.append(val)
else:
del new_d[val]
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 |
9675c8b9-337a-4fd1-bb8f-8e3510c7f703
| 2,016 |
2,534 |
def swap_unique_keys_values(d):
new_d = {}
dups = []
for key, val in list(d.items()):
if val not in dups:
new_d[val] = key
dups.append(val)
else:
del new_d[val]
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 |
9675c8b9-337a-4fd1-bb8f-8e3510c7f703
| 2,016 |
11,764 |
def swap_unique_keys_values(d):
new_d = {}
dups = []
for key, val in list(d.items()):
if val not in dups:
new_d[val] = key
dups.append(val)
else:
del new_d[val]
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 |
9675c8b9-337a-4fd1-bb8f-8e3510c7f703
| 2,016 |
13,984 |
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 |
5cf0f5b5-a91e-4c33-8ac1-92aa868cd3b0
| 2,016 |
3,192 |
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 |
5cf0f5b5-a91e-4c33-8ac1-92aa868cd3b0
| 2,016 |
20,309 |
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 |
5cf0f5b5-a91e-4c33-8ac1-92aa868cd3b0
| 2,016 |
17,682 |
def swap_unique_keys_values(d):
new_dict = 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'}
| false |
99a8a900-efcf-4a9e-86ba-fdd0df4312d3
| 2,016 |
12,616 |
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 |
99a8a900-efcf-4a9e-86ba-fdd0df4312d3
| 2,016 |
9,420 |
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 |
99a8a900-efcf-4a9e-86ba-fdd0df4312d3
| 2,016 |
28,577 |
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 |
99a8a900-efcf-4a9e-86ba-fdd0df4312d3
| 2,016 |
13,341 |
def swap_unique_keys_values(d):
seen = []
return {v: k for k, v in list(d.items())}
|
swap_unique_keys_values
|
swap_unique_keys_values
|
Swap the keys of a dictionary with its unique values.
|
assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'}
| false |
59b507a0-b0a2-42b7-a6af-736ab71c8fe1
| 2,016 |
7,299 |
def swap_unique_keys_values(d):
values = list(d.values())
return {v: k for k, v in list(d.items()) if values.count(v) < 2}
|
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 |
59b507a0-b0a2-42b7-a6af-736ab71c8fe1
| 2,016 |
4,938 |
def swap_unique_keys_values(d):
values = list(d.values())
return {v: k for k, v in list(d.items()) if values.count(v) < 2}
|
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 |
59b507a0-b0a2-42b7-a6af-736ab71c8fe1
| 2,016 |
29,918 |
def swap_keys_values(d):
return {k: v for v, k 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 |
f0b2f578-ae0f-4ddc-94e9-204708d09f37
| 2,016 |
37,124 |
def swap_keys_values(d):
return {k: v for v, k 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 |
f0b2f578-ae0f-4ddc-94e9-204708d09f37
| 2,016 |
31,270 |
def swap_unique_keys_values(d):
values = list(d.values())
items = [(y, x) for x, y in list(d.items())]
d2 = {v: k for v, k in sorted(items) if values.count(v) == 1}
return d2
|
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 |
f0b2f578-ae0f-4ddc-94e9-204708d09f37
| 2,016 |
7,963 |
def swap_unique_keys_values(d):
values = list(d.values())
items = [(y, x) for x, y in list(d.items())]
d2 = {v: k for v, k in sorted(items) if values.count(v) == 1}
return d2
|
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 |
f0b2f578-ae0f-4ddc-94e9-204708d09f37
| 2,016 |
39,540 |
def swap_unique_keys_values(d):
values = list(d.values())
items = [(y, x) for x, y in list(d.items())]
d2 = {v: k for v, k in sorted(items) if values.count(v) == 1}
return d2
|
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 |
f0b2f578-ae0f-4ddc-94e9-204708d09f37
| 2,016 |
27,131 |
def swap_keys_values(d):
e = {}
for k, v in d:
e[v] = k
return e
|
swap_keys_values
|
swap_keys_values
|
Swap the keys of a dictionary with its values.
|
assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'}
| false |
15c8870d-4f5a-4578-b0fb-4dd4a4402626
| 2,016 |
36,734 |
def swap_keys_values(d):
e = {}
for k, v in list(d.items()):
e[v] = k
return e
|
swap_keys_values
|
swap_keys_values
|
Swap the keys of a dictionary with its values.
|
assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'}
| true |
15c8870d-4f5a-4578-b0fb-4dd4a4402626
| 2,016 |
13,032 |
def swap_keys_values(d):
e = {}
for k, v in list(d.items()):
e[v] = k
return e
|
swap_keys_values
|
swap_keys_values
|
Swap the keys of a dictionary with its values.
|
assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'}
| true |
15c8870d-4f5a-4578-b0fb-4dd4a4402626
| 2,016 |
21,122 |
def swap_keys_values(d):
return {k: v for v, k 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 |
54b87e3d-5711-4a83-a6d1-ed14ae588835
| 2,016 |
8,640 |
def swap_keys_values(d):
return {k: v for v, k 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 |
54b87e3d-5711-4a83-a6d1-ed14ae588835
| 2,016 |
8,805 |
def swap_unique_keys_values(d):
values = list(d.values())
items = [(y, x) for x, y in list(d.items())]
d2 = {v: k for v, k in sorted(items) if values.count(v) == 1}
return d2
|
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 |
54b87e3d-5711-4a83-a6d1-ed14ae588835
| 2,016 |
34,332 |
def swap_unique_keys_values(d):
values = list(d.values())
items = [(y, x) for x, y in list(d.items())]
d2 = {v: k for v, k in sorted(items) if values.count(v) == 1}
return d2
|
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 |
54b87e3d-5711-4a83-a6d1-ed14ae588835
| 2,016 |
29,317 |
def swap_keys_values(d):
d = dict((v, k) for k, v in d.items())
|
swap_keys_values
|
swap_keys_values
|
Swap the keys of a dictionary with its values.
|
assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'}
| false |
1a650795-f8bf-47db-90f0-c896555da6d7
| 2,016 |
1,983 |
def swap_keys_values(d):
return dict((v, k) for k, v in d.items())
|
swap_keys_values
|
swap_keys_values
|
Swap the keys of a dictionary with its values.
|
assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'}
| true |
1a650795-f8bf-47db-90f0-c896555da6d7
| 2,016 |
2,250 |
def swap_keys_values(d):
return {(v, k) for k, v in d.items()}
|
swap_keys_values
|
swap_keys_values
|
Swap the keys of a dictionary with its values.
|
assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'}
| false |
1a650795-f8bf-47db-90f0-c896555da6d7
| 2,016 |
41,552 |
def swap_keys_values(d):
print([(4, 'a'), (7, 'b'), (10, 'c')])
|
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 |
40,671 |
def swap_keys_values(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 |
35,280 |
def swap_keys_values(d):
print(dict((v, k) for k, v in d.items()))
|
swap_keys_values
|
swap_keys_values
|
Swap the keys of a dictionary with its values.
|
assert swap_keys_values({})=={} and swap_keys_values({'1': 'a'})=={'a': '1'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'a': '3', 'b': '2'}
| false |
1a650795-f8bf-47db-90f0-c896555da6d7
| 2,016 |
21,560 |
def swap_keys_values(d):
print(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 |
21,088 |
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 |
a4f49b67-25e5-43c2-a48c-827c1919659f
| 2,016 |
17,952 |
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 |
a4f49b67-25e5-43c2-a48c-827c1919659f
| 2,016 |
3,278 |
def swap_unique_keys_values(d):
return dict([(v, k) for k, v in list(d.items()) if list(d.values()).
count(v) == 1])
|
swap_unique_keys_values
|
swap_unique_keys_values
|
Swap the keys of a dictionary with its unique values.
|
assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'}
| true |
68f143f9-a076-4b95-afe1-e3828c2d0f4e
| 2,016 |
11,931 |
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 |
22,339 |
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 |
a4f49b67-25e5-43c2-a48c-827c1919659f
| 2,016 |
24,620 |
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 |
a4f49b67-25e5-43c2-a48c-827c1919659f
| 2,016 |
17,930 |
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 |
a4f49b67-25e5-43c2-a48c-827c1919659f
| 2,016 |
36,151 |
def swap_keys_values(d):
return {k: v for v, k 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 |
f94d128e-c997-4cca-8a7e-2216c3966829
| 2,016 |
23,990 |
def swap_keys_values(d):
return {k: v for v, k 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 |
f94d128e-c997-4cca-8a7e-2216c3966829
| 2,016 |
5,124 |
def swap_keys_values(d):
d = dict((v, k) for k, v in list(d.items()))
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 |
37,633 |
def swap_unique_keys_values(d):
return dict([(v, k) for k, v in list(d.items()) if list(d.values()).
count(v) == 1])
|
swap_unique_keys_values
|
swap_unique_keys_values
|
Swap the keys of a dictionary with its unique values.
|
assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'}
| true |
68f143f9-a076-4b95-afe1-e3828c2d0f4e
| 2,016 |
31,468 |
def swap_unique_keys_values(d):
return dict([(v, k) for k, v in list(d.items()) if list(d.values()).
count(v) == 1])
|
swap_unique_keys_values
|
swap_unique_keys_values
|
Swap the keys of a dictionary with its unique values.
|
assert swap_unique_keys_values({})=={} and swap_unique_keys_values({'1': 'a'})=={'a': '1'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'c', '4': 'd'})=={'a': '1', 'b': '2', 'c': '3', 'd': '4'} and swap_unique_keys_values({'1': 'a', '2': 'b', '3': 'a'})=={'b': '2'}
| true |
68f143f9-a076-4b95-afe1-e3828c2d0f4e
| 2,016 |
15,652 |
def swap_keys_values(d):
return {d[key]: key for key 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'}
| true |
68f143f9-a076-4b95-afe1-e3828c2d0f4e
| 2,016 |
14,714 |
def swap_keys_values(d):
return {d[key]: key for key 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'}
| true |
68f143f9-a076-4b95-afe1-e3828c2d0f4e
| 2,016 |
35,182 |
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 |
28,695 |
def swap_keys_values(d):
d = dict((v, k) for k, v in list(d.items()))
print(sorted(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 |
17,865 |
def swap_unique_keys_values(d):
values = list(d.values())
items = [(y, x) for x, y in list(d.items())]
d2 = {v: k for v, k in sorted(items) if values.count(v) == 1}
return d2
|
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 |
f94d128e-c997-4cca-8a7e-2216c3966829
| 2,016 |
11,168 |
def swap_unique_keys_values(d):
values = list(d.values())
items = [(y, x) for x, y in list(d.items())]
d2 = {v: k for v, k in sorted(items) if values.count(v) == 1}
return d2
|
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 |
f94d128e-c997-4cca-8a7e-2216c3966829
| 2,016 |
32,137 |
def swap_unique_keys_values(d):
values = list(d.values())
items = [(y, x) for x, y in list(d.items())]
d2 = {v: k for v, k in sorted(items) if values.count(v) == 1}
return d2
|
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 |
f94d128e-c997-4cca-8a7e-2216c3966829
| 2,016 |
19,880 |
def swap_keys_values(d):
d = dict((v, k) for k, v in list(d.items()))
print(collections.OrderedDict(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 |
29,351 |
def swap_keys_values(d):
d = dict((v, k) for k, v in list(d.items()))
d = collections.OrderedDict(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 |
20,593 |
def swap_keys_values(d):
d = dict((v, k) for k, v in list(d.items()))
d = collections.OrderedDict(sorted(list(d.items()), key=lambda t: t[0]))
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 |
9,299 |
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(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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.