Please check my code below and make necessary corrections. It is giving me an error message.
The assignment is shown below.
Create a function
manipulate_datathat does the following
Accepts as the first parameter a
stringspecifying the data structure to be usedlist,setordictionaryAccepts as the second parameter the data to be manipulated based on the data structure specified e.g
[1, 4, 9, 16, 25]for alistdata structureBased off the first parameter
- return the reverse of a list or
- add items
"ANDELA","TIA"and"AFRICA"to the set and return the resulting set- return the keys of a dictionary.
My solution code is below:
def manipulate_data(argument1, argument2):
if argument1 == "list":
argument2.reverse()
return argument2
if argument1 == "set":
argument2.add("ANDELA")
argument2.add("TIA")
argument2.add("AFRICA")
return argument2
if argument1 == "dictionary":
argument2.keys()
return argument2
I don't know if I am making sense at all. The error messages received are:
Total Specs: 3 Total Failures: 2
test_manipulate_dictionary
Failure in line 23, in test_manipulate_dictionary self.assertEqual(result, ["grapes", "mangoes", "apples", "oranges"], msg = "Dictionary not manipulated correctly") AssertionError: Dictionary not manipulated correctly
and
test_manipulate_set
Failure in line 19, in test_manipulate_set self.assertEqual(result, {"a", "b", "c", "d", "e", "ANDELA", "TIA", "AFRICA"}, msg = "Set not manipulated correctly") AssertionError: Set not manipulated correctly