Need help on a project To :"Create a class called BankAccount with the following parameters "

Erik python at lucidity.plus.com
Sun Dec 27 10:26:44 EST 2015


On 27/12/15 15:02, lee wrote:
> the code i have tested base on Cameron's code
>
> def manipulate_data(kind, data):
>     if kind == 'list':
>      return list(data)[::-1]
>
>     elif kind == 'set':
>          return set(data)
>     elif kind == 'dictionary':
>       return dict( data)
>
> manipulate_data("list", range(1,6))
> a = manipulate_data("set", {"a", "b", "c", "d", "e"})
> a.add("ANDELA")
> a.add("TIA")
> a.add("AFRICA")
> b = manipulate_data("dictionary", {"apples": 23, "oranges": 15, "mangoes": 3, "grapes": 45})
> list(b.keys())
[snip]
> i guess i passed the first requirement to return the reversed order of the list and believe i messed up when creating a set then add data to the set, also something is wrong with returning the keys of the dictionary
>
>
> can someone point out the error in my code and the meaning of the unittes error?

You're nearly there.

After you've called the function, anything you do to the result is not 
done BY the function and will therefore not be done when called by other 
code.

The unit test that calls the function will not do those things. It 
expects them to already be done.

So ... what changes to your function do you think would fix that?

Regards,
E.




More information about the Python-list mailing list