Menu

[Solved]-Python Professor Gave Us Main Function E Demonstrate Removing Middle Element Data List One Q37286885

PYTHON

My professor gave us the main function, which is:

#e. Demonstrate removing the middle element.
data = list(ONE_TEN)
removeMiddle(data)
print(“After removing the middle element(s): “, data)

I wrote the codes, but I am supposed to return the value as’data.’ But I only know how to make a ‘new’ variable and assign anew list. How do I fix my codes so that I could return ‘data’? Thisis the function I wrote:

def removeMiddle(data):
first = int((len(data) / 2) – 1)
new = []
for i in range(first):
nwq.append(data[i])
if (len(data) % 2 == 0):
for i in range(first, len(data) – 2):
new.append(data[i + 2])
else:
for i in range(first, len(data) – 1):
new.append(data[i + 1])
return new

Expert Answer


Answer to PYTHON My professor gave us the main function, which is: #e. Demonstrate removing the middle element. data = list(ONE_TE… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *