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
31 changes: 23 additions & 8 deletions python_solution.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
def refine_parameter(obj):
"""
Refine a parameter
Returns a parameter parsed to its expected type
"""
if isinstance(obj, dict):
return refine_parameters(obj)
elif isinstance(obj, list):
return [refine_parameter(o) for o in obj]
else:
try:
return int(obj)
except ValueError:
if obj in ["true", "false"]:
return obj == "true"
return obj

def refine_parameters(data: dict):
'''Refine the parameters of a dictionary

Returns:
Return a dictionary of cleaned input
'''
def refine_parameters(data: dict):
"""
Refine the parameters of a dictionary
Returns a dictionary of cleaned input
"""
clean_dict = {}

# Write your code here.

for key, value in data.items():
clean_dict[key] = refine_parameter(value)
return clean_dict