[Tutor] URGENT: PYTHON QUESTION

Joel Goldstick joel.goldstick at gmail.com
Thu Mar 31 08:03:41 EDT 2016


direct your question to tutor at python.org.  Also provide the results you
have gotten from your code, and what you think is wrong

On Thu, Mar 31, 2016 at 7:46 AM, accessmuah <accessmuah at yahoo.com> wrote:

> Hi
>
>
>
> Pls, helped review it as i cant proceed to the next stage
>
> def manipulate_data(kind, data):
>     if kind == 'list':
>         return list(data)[::-1]
>     elif kind == 'set':
>         data=set({"a", "b", "c", "d", "e", "ANDELA", "TIA", "AFRICA"})
>         return set(data)
>     elif kind == 'dictionary':
>         return dict.keys(data)
> manipulate_data("list", range(1,6))
> manipulate_data("set", {"a", "b", "c", "d", "e", "ANDELA", "TIA",
> "AFRICA"})
> manipulate_data("dictionary", {"apples": 23, "oranges": 15, "mangoes": 3,
> "grapes": 45})
>
>
>
>
> I
> DS LAB
> Create a function manipulate_data that does the following
> Accepts as the first parameter a string specifying the data structure to
> be used "list", "set" or "dictionary" Accepts as the second parameter the
> data to be manipulated based on the data structure specified e.g [1, 4,
> 9, 16, 25] for a list data structure Based 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
>
>
> Thanks
>
> Regards
>
> Shittu
>
>
> IF YOU THINK YOU CAN'T, YOU CAN'T; IF YOU YOU THINK YOU CAN, YOU CAN !!!
> N.G.U
>
>
>
>
>


-- 
Joel Goldstick
http://joelgoldstick.com/ <http://joelgoldstick.com/stats/birthdays>
http://cc-baseballstats.info/


More information about the Tutor mailing list