This is working fine. What is the problem?
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) print manipulate_data("list", range(1,6)) print manipulate_data("set", {"a", "b", "c", "d", "e", "ANDELA", "TIA", "AFRICA"}) print manipulate_data("dictionary", {"apples": 23, "oranges": 15, "mangoes": 3, "grapes": 45}) regards, Sarma. On Thu, Mar 31, 2016 at 10:15 PM, Steven D'Aprano <st...@pearwood.info> wrote: > On Thu, Mar 31, 2016 at 12:47:21PM +0000, accessmuah via Tutor wrote: >> Hi, >> Pls, assist with this Question....Kindly stroll to the end > >> DS LABCreate a function manipulate_data that does the followingAccepts >> 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 >> >> >> My Answer below - Kindly helped reviewed it >> 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}) > > Unfortunately your code has been mangled by the email. Can you try > sending it again WITHOUT using Yahoo's "Rich Text" (HTML mail)? > > I will try to reverse-engineer what you meant: > > 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}) > > > Is that what you intended? > > > >> CODE RESULT >> >> >> But i cant proceed to next stage...see error below Pls assist > > I looked below, but you have not included the error. Perhaps you > included it as an attachment? In that case, it would probably be > deleted, and if it is a screen-shot, it will be useless to anyone who is > blind or visually impaired and reading this using a screen reader. > > Please COPY and PASTE the text of the error into your email. > > > > > > >> >> >> >> Thanks >> Regards >> Shittu >> _______________________________________________ >> Tutor maillist - Tutor@python.org >> To unsubscribe or change subscription options: >> https://mail.python.org/mailman/listinfo/tutor > _______________________________________________ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor