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
TECHNICAL TERMS: the adderess of a website
riadik2000 [5.3K]
Yes very interesting
6 0
2 years ago
If you try to add a new item to a full stack the resulting condition is called a(n)?
Butoxors [25]

Answer:

it's called an overflow

3 0
2 years ago
Need the answer ASAP plz !!!!!
Evgesh-ka [11]
Performance would be the answer
3 0
3 years ago
How can random numbers in a range be generated in Java?.
Ksju [112]

Answer:

Java oh Na Na my  

Explanation:

5 0
2 years ago
How do i build a supercomputer.?
stira [4]
You will need one head node, at least a dozen identical compute nodes, an Ethernet switch, a power distribution unit, and a rack. Determine the electrical demand, cooling and space required. Also decide on what IP address you want for your private networks, what to name the nodes, what software packages you want installed, and what technology you want to provide the parallel computing capabilities
3 0
3 years ago
Other questions:
  • Dial-up connections can be made over a(n) ____ line or phone line. isdn dsl ipx tcp/ip
    12·1 answer
  • In regard to protective actions for explosive devices, the area where the blast originates is referred to as ___________ perimet
    8·1 answer
  • A server that provides data transfer and storage space at remote locations is called a
    7·1 answer
  • Write the definition of a method min that has two int parameters and returns the smaller.
    9·1 answer
  • Describe the best way to deal with a difficult co-worker?
    13·2 answers
  • You dad has given you his old digital scanner for your new computer. you plug it into the usb drive on your windows 8 computer b
    8·1 answer
  • What is Celeste? ( This is for my coding class )
    6·2 answers
  • What are the characteristics of the sorting and grouping options in Outlook? Check all that apply. Columns can be sorted by clic
    15·2 answers
  • What is the output?
    7·1 answer
  • MmfbfMMMMMMMMMMMMMMMMMmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!