Respuesta :
Answer:
I am writing a Python program:
For taking input from user:
user_input = input() # takes input from user
short_names = user_input.split() #splits user_input into list of strings
short_names.pop(0) # removes the first element of the list i.e. Gertrude
short_names[-1] = "Joe" #sets the last element to Joe
print(short_names) #prints modified list of Sam Ann Joe
If you do not want to take input from user:
short_names=['Gertrude', 'Sam', 'Ann', 'Joseph'] #list of 4 elements
short_names=short_names[1:] # removes the first element Gertrude
short_names.pop() # removes last element i.e. Joseph from list
short_names.append('Joe') #adds Joe to the end of the list
print(short_names) #prints modified list Sam Ann Joe
If you do not want to use pop() and append() methods:
short_names = ['Gertrude', 'Sam', 'Ann', 'Joseph'] #creates list of 4 values
short_names = short_names[1:] # removes first value i.e. Gertrude from list
short_names[-1] = "Joe" #set the last element to Joe
print(short_names) #prints modified list Sam Ann Joe
Explanation:
The first program takes the names from the user, splits them into list of strings, then pop(0) has given index value 0 which means 1st value in the list. So it removes and returns first value from the list. Next statement sets the last value of list to Joe.
The second program has a hard coded list ['Gertrude', 'Sam', 'Ann', 'Joseph']
short_names = short_names[1:] removes the first value of the short_names list i.e. Gertrude. Next pop() removes and returns last value in the list i.e. Joseph from list. Last statement append('Joe') adds Joe to the end of the list.
The third program has a list of 4 elements. short_names = short_names[1:] removes first value i.e. Gertrude from list and short_names[-1] = "Joe" sets the last element to Joe.



The function was implemented using the JavaScript language, the shift, pop and push function was used to get the desired output
Array and String Operations
The function bellow is written in JavaScript
function shortName (short_names){
short_names.shift() // The first element "Gertrude" was removed
short_names.pop() //The last element "Joseph" was removes
short_names.push("joe") //"Joe" is added to the new list
return short_names //The new list is returned as output
}
Learn more about array operation here:
https://brainly.com/question/26104158