def get_new_task(values_dict):
"" "
param: values_dict (dict) - a dictionary that holds
STRING values for all keys
Helper functions:
check_valid_field
For each key and value in the provided dictionary, calls
the check_valid_field() to verify that they are valid.
Does not modify values_dict.
returns: a NEW dictionary that stores the values from the values_dict
converted to the correct type / value, after each necessary value
was verified by the check_valid_field().
The only field that needs conversion is "done", since it is
supposed to be stored as a Boolean and "rank", stored as an
int (if its possible to convert it from string).
Otherwise, returns the name of the invalid key or the valid key that
stores the invalid data.
"" "
for ...:
if check_valid_field(..) != "valid":
return ...
... = values_dict.copy() # Make a copy of the values
# TODO: Convert the string to Boolean, based on if ' y ' or 'n' is stored
...
# TODO: Convert the string to int for 'rank' field if possible
# HINT: You can use .isdigit() to check if the string can be converted to an integer
...
return dots
def get new task(values dict:
param: values dict (dict) - a dictionary that holds STRING values for all keys
Helper functions: - check_valid field
For each key and value in the provided dictionary, calls the check valid field() to verify that they are valid. Does not modify values_dict.
returns: a NEw dictionary that stores the values from the values dict
converted to the correct type / value, after each necessary value was verified by the check valid field().
The only field that needs conversion is "done", since it is supposed to be stored as a Boolean and "rank", stored as an int (if its possible to convert it from string).
Otherwise, returns the name of the invalid key or the valid key that
stores the invalid data.
for...: if check valid field(...) != "valid": return.
- values dict.copy # Make a copy of the values
# ToDo: Convert the string to Boolean, based on if 'y' or 'n' is stored
# HINT: You can use .isdigit() to check if the string can be converted to an integer
return.