Passing set, list and Dictionary as argument to Python function
<p>Please check my code below and make necessary corrections. It is giving me an error message.</p>

<p>The assignment is shown below.</p>

<blockquote>
  <p>Create a function <code>manipulate_data</code> that does the following</p>
  
  <ol>
  <li><p>Accepts as the first parameter a <code>string</code> specifying the data structure to be used <code>list</code>, <code>set</code> or <code>dictionary</code></p></li>
  <li><p>Accepts as the second parameter the data to be manipulated based on the data structure specified e.g <code>[1, 4, 9, 16, 25]</code> for a <code>list</code> data structure</p></li>
  <li><p>Based off the first parameter</p>
  
  <ul>
  <li>return the reverse of a list or</li>
  <li>add items <code>"ANDELA"</code>, <code>"TIA"</code> and <code>"AFRICA"</code> to the set and return the resulting set</li>
  <li>return the keys of a dictionary.</li>
  </ul></li>
  </ol>
</blockquote>

<p>My solution code is below:</p>

<pre class="lang-py prettyprint-override"><code>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
</code></pre>

<p>I don't know if I am making sense at all. The error messages received are:</p>

<pre><code>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
</code></pre>

<p>and</p>

<pre><code>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
</code></pre>