Skip to content
This repository was archived by the owner on Jan 2, 2024. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions python_solution.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@

def refine_val(x: string):
return int(x) if x.isnumeric() else True if x == "true" else False if x == "false" else x
def refine_parameters(data: dict):
'''Refine the parameters of a dictionary

Returns:
Return a dictionary of cleaned input
'''
clean_dict = {}

# Write your code here.
for key, value in data.items(): #iteritems is only python 2! oops
if isinstance(value, dict):
clean_dict[key] = refine_parameters(value)
elif isinstance(value, list):
clean_dict[key] = [refine_val(x) for x in value]
else:
clean_dict[key] = refine_val(value)

return clean_dict