Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Erik Newsgroups: comp.lang.python Subject: Re: Need help on a project To :"Create a class called BankAccount with the following parameters " Date: Sun, 27 Dec 2015 15:26:44 +0000 Lines: 39 Message-ID: References: <20151226000941.GA36035@cskk.homeip.net> <4dba6e6d-68f5-42af-b9d8-8bb1bd92312b@googlegroups.com> <6890848e-bffa-4cac-8a3b-3f8a529b7cd9@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de J6Ewh4feLvm2rAr5kBQJnQb1PGGXooBh8o5Wq9R5orIg== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'elif': 0.04; 'that?': 0.05; 'data):': 0.07; 'subject:help': 0.07; 'def': 0.13; 'subject: \n ': 0.15; 'things.': 0.15; '"d",': 0.16; '23,': 0.16; 'data)': 0.16; 'dict(': 0.16; 'expects': 0.16; 'from:addr:python': 0.16; 'received:84.93': 0.16; 'received:84.93.230': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'reversed': 0.16; 'set,': 0.16; 'subject:class': 0.16; 'subject:parameters': 0.16; 'wrote:': 0.16; 'subject:project': 0.18; 'changes': 0.20; 'fix': 0.21; 'to:2**1': 0.21; 'function,': 0.22; 'keys': 0.22; 'code.': 0.23; 'nearly': 0.23; 'header:In-Reply-To:1': 0.24; 'header:User-Agent:1': 0.26; 'error': 0.27; 'function': 0.28; "skip:' 10": 0.28; 'dictionary': 0.29; 'there.': 0.30; 'creating': 0.30; 'code': 0.30; '15,': 0.30; 'guess': 0.31; 'received:84': 0.32; 'point': 0.33; 'add': 0.34; 'list': 0.34; 'done': 0.35; 'returning': 0.35; 'something': 0.35; 'unit': 0.35; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'done.': 0.37; 'requirement': 0.37; 'wrong': 0.38; 'anything': 0.38; 'someone': 0.38; 'test': 0.39; 'data': 0.39; 'subject:the': 0.39; 'received:192': 0.39; 'to:addr:python.org': 0.40; 'subject:with': 0.40; 'called': 0.40; 'your': 0.60; 'subject:Need': 0.61; 'charset:windows-1252': 0.62; 'believe': 0.66; 'therefore': 0.67; 'messed': 0.84 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.1 cv=Iat6Ijea c=1 sm=1 tr=0 a=Ypmeq7T0cKALDUsRPCToMg==:117 a=Ypmeq7T0cKALDUsRPCToMg==:17 a=0Bzu9jTXAAAA:8 a=EBOSESyhAAAA:8 a=N659UExz7-8A:10 a=xFRB-WQywxNxRjIA60sA:9 a=pILNOxqGKmIA:10 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 In-Reply-To: <6890848e-bffa-4cac-8a3b-3f8a529b7cd9@googlegroups.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:100905 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.