please i have been trying this for a while its not working please someone should please help me out
def manipulate_data(lst, n):
new_n =
new_lst = lst.append(n)
for i in lst:
new_lst = new_lst.reverse()
return new_lst
manipulate_data([3, 5, 6, 8,], [“ghat”, 6, 7, “jane”])
The code in your post is not intact, can’t be run to reproduce whatever it is that you are not describing.
So make sure that the problem can be reproduced, and explain what is going on, what you expect.
Also consider what information you are missing to solve it on your own - the more specific your question is, the better for everyone.
ob boss the question is:
create a function manipulate_data that:
accepts the first parameter a string specifying the data structure to be either list or set or dictionary
accepts as the second parameter the data to be manipulated based on the data structure specified
based on the first parameter:
— return the reverse of a list or
—add items
—return the keys of a dictionary
thanks am grateful
Sure, those are the instructions. But those don’t tell me what’s wrong about your code, or what your code is!
The information missing is 1) what is your code 2) in what way does it behave differently from what you want
each time i run the code i get invalid syntex for the last the call of manipulate_data([3, 5, 6, 8,], [“ghat”, 6, 7, “jane”])
If you want me to look at that then I would still need the code.
([3, 5, 6, 8,], ["ghat", 6, 7, "jane"])
Is correct syntax though, so it’s likely that the mistake is higher up, and that it’s pointing at this line because this is when it stops making sense.
thats the code but if not for the syntex error is my code in the right direction?
Until I can copy what you post and run that, you haven’t posted the code.
def manipulate_data(lst, n):
new_n =
new_lst = lst.append(n)
for i in lst:
new_lst = new_lst.reverse()
return new_lst
manipulate_data([3, 5, 6, 8,], [“ghat”, 6, 7, “jane”])
If you copy that and run it. Do you get the same error message?
If not, and you won’t, then how could I possibly use that to determine what’s wrong with your code?
Compare these:
for n in range(5):
print n
for n in range(5):
print n
Those are in no way equivalent.
def manipulate_data(lst, n):
new_n = []
new_lst = lst.append(n)
for i in lst:
new_lst = new_lst.reverse()
return new_lst
manipulate_data([3, 5, 6, 8,], [“ghat”, 6, 7, “jane”])
something like this right?