1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Korolek [52]
2 years ago
13

Given the lists list1 and list2 that are of the same length, create a new list consisting of the last element of list1 followed

by the last element of list2, followed by the second to last element of list1, followed by the second to last element of list2, and so on (in other words the new list should consist of alternating elements of the reverse of list1 and list2). For example, if list1 contained [1, 2, 3] and list2 contained [4, 5, 6], then the new list should contain [3, 6, 2, 5, 1, 4]. Associate the new list with the variable list3.

Computers and Technology
1 answer:
Inessa [10]2 years ago
6 0

Answer:

list1 = [1, 2, 3]

list2 = [4, 5, 6]

list3 = []

newlist = []

for i in list1:

   for j in list2:

       if list1.index(i) == list2.index(j):

           newlist.append(j)

           newlist.append(i)

           break

   

for i in reversed(newlist):

   list3.append(i)

print(list3)

Explanation:

The programming language used is python.

List 1 and 2 are initialized, and two empty lists are initialized too, these two lists are going to be used in generating the new list.

Two FOR loops are used for both list one and two respectively, to iterate through their content, the IF statement and the break is placed within the for loop to ensure that there is no repetition.

The index of list 1 and list 2 are appended (added) to a new list one at a time.

The new list is then reversed and its content are added to list 3 to give the final solution.

NOTE: The reason a separate list was created was because the reversed() function does not return a list, so in order to get the list, it must be added to an empty list as you reverse it.

You might be interested in
Which branch of science helps avoid or minimize stress-related injuries at workplace?
worty [1.4K]
Psychology, because psychology is the study of how the mind works, and therefor what causes stress.
3 0
3 years ago
Read 2 more answers
Holi alguien sabe como cambiar el gamertag en XBox App (para iOS)?
Schach [20]

Answer:

Hola, cambiar tu gamertag (el nombre o apodo que te identifica en los juegos de XBox en línea) es muy sencillo. Simplemente debes ingresar al menú principal de tu aplicación XBox App, y una vez allí seleccionar la imagen que te identifica como usuario. Al clickear allí, podrás seleccionar la opción Personalizar, donde se desplegará un menú de opciones dentro de las cuales se encontrará la de cambiar tu gamertag o nombre de usuario. Recuerda que solo podrás cambiar tu gamertag en forma gratuita una única vez.

3 0
2 years ago
What are the main differences between photo and video formats?
horrorfan [7]

Answer:

Nothing just the video is series of photos together

Explanation:

8 0
3 years ago
The advantage of returning a structure type from a function when compared to returning a fundamental type is that a. the functio
inessss [21]

Answer:

The advantage of returning a structure type from a function when compared to returning a fundamental type is that

e. a and b only.

Explanation:

One advantage of returning a structure type from a function vis-a-vis returning a fundamental type is that the function can return multiple values.  The second advantage is that the function can return can an object.  This implies that a function in a structure type can be passed from one function to another.

7 0
2 years ago
Face-to-face human contact has lost its importance as a means of communication because of the growing prevalence of e-mail, web-
chubhunter [2.5K]

Answer:

b

Explanation:

7 0
3 years ago
Other questions:
  • An employee is angry with his boss and wants to sabotage the company. To accomplish this he secretly changes some of the values
    7·1 answer
  • Can you help me correct a sentence?
    13·1 answer
  • Using information from the lesson, explain how new technologies change your experience as a consumer.
    5·2 answers
  • Do debit cards offer the highest level of fraud pretection?
    10·1 answer
  • Which of the following is NOT areserved word in Java?intpublicstaticnum
    9·1 answer
  • Hi guys, Im making a game. I want to make a collision event, but what is the code for making the wall and the box collide. I rea
    6·1 answer
  • What sorts of changes have you been observing in your society in your society in comparison in last 3 years​
    13·1 answer
  • In this class, it is very common for your computer screen to look like this. What is this?​
    5·1 answer
  • . Define the process of Technological relationship
    12·1 answer
  • What is business agility
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!