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
27 changes: 26 additions & 1 deletion python_solution.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,33 @@ def refine_parameters(data: dict):
Returns:
Return a dictionary of cleaned input
'''
clean_dict = {}
clean_dict = data # Copy

# Write your code here.
for key in clean_dict:

entry = clean_dict[key]

# If item is string
if type(entry) == str:
if entry.isdigit():
clean_dict[key] = int(entry)
# Boolean
elif entry == "true":
clean_dict[key] = True
elif entry == "false":
clean_dict[key] = False

# If item is list
elif type(entry) == list:
if type(entry[0]) == str and entry[0].isdigit():
# Convert strings to numbers in list
for i, item in enumerate(entry):
clean_dict[key][i] = int(clean_dict[key][i])

# If item is dict
elif type(entry) == dict:
refine_parameters(entry)


return clean_dict