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]
3 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]3 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
5 pros and cons about 5g plz i need this badly
lisov135 [29]
5g creates a greater bandwidth
7 0
3 years ago
Read 2 more answers
Java initializes all variables with the default values of its data type . *
ahrayia [7]

Answer:

This is correct.

Explanation:

int is initialized with 0

object references with null

etc.

8 0
3 years ago
An__________chart takes up less space than a chart sheet.
neonofarm [45]
<span>An embedded chart takes up less space than a chart sheet.</span><span />
7 0
4 years ago
Which numbering system is used for some network addresses, to describe colors
FromTheMoon [43]
Hexadecimal it describes locations in memory
5 0
3 years ago
Suppose that we have a ternaryrelationship R between entity sets A, B, and C such that (i) A has a key constraint; and (ii) Chas
lutik1710 [3]
Lol i mean it could definitely be any of the choices lol i don’t have a clue lol
3 0
4 years ago
Other questions:
  • Hexadecimal (19BACDFE)H into Octal. Please write step by step.
    6·1 answer
  • Donna is in the Outlook Today window and clicks the F1 button on her keyboard. What is Donna most likely trying to do?
    11·2 answers
  • If an external server needs to communicate with servers inside the green zone, which network setting on smoothwall can be opened
    15·2 answers
  • Where is most of the information processed in a computer
    13·1 answer
  • 1. Defines and uses an interface block to connect to the test program and the DUT. The interface block should also contain a clo
    11·1 answer
  • What does a production possibilities curve represent?Which of the following statements are true? Economic stability means fair d
    9·1 answer
  • Program MATH_SCORES: Your math instructor gives three tests worth 50 points each. You can drop one of the test scores. The final
    7·1 answer
  • Order the steps for using the Rules Wizard to create an email rule.
    15·1 answer
  • One advantage of a PAN​
    10·2 answers
  • How dose computers it use the information to solve problems
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!