Respuesta :

Answer:

def prolog(mylist):

   for x in range(2):

       del mylist[0]

       del mylist[-1]

   return mylist

scores = [23, 23,45, 45, 65, 65]

result = prolog(scores)

Explanation:

The del keyword in python is used to delete variable and items in a data structure like in a list. To delete a list, specify the list name and also an index to delete an item.

The function 'prolog' loops through a list to delete the first and the last two items.

fichoh

The program deleted the firsts and last two elements in a list. The program is written in python 3 and it goes thus :

def prolog(word_list):

#initialize a function named prolog that takes a list of strings as an argument.

for letter in range(2):

#iterate twice over the list:

del word_list[0]

#delete the first word for each iteration

del word_list[-1]

#delete the last word for each iteration

return word_list

#return the list

words = ['a','b', 'c', 'd' , 'e']

A sample run of the program is attached.

print(prolog(words))

Learn more :https://brainly.com/question/15687460

Ver imagen fichoh
Q&A Education