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
Who has pad let and wants to talk
vredina [299]

Answer:

I do.

Explanation:

8 0
3 years ago
Read 2 more answers
What is the range for copper tape
jeyben [28]

Answer:

I like the song "Angel"

3 0
2 years ago
Pda bkhhksejc pnwjoynelp dwo xaaj ajykzaz ywj ukq zaykza ep???<br><br><br> The Key Value is 22
Sindrei [870]

Answer:

The following transcript has been encoded can you decode it???

Explanation:

It is a ceasar cipher. Shift every letter in the alphabet by 22 positions.

3 0
3 years ago
Matthew is running a study on the effects of room temperature on performance on an algebra test. One group takes the test in a r
qaws [65]

Answer:

Independent variable is temperature

Explanation:

An equation has this form:    Y= f(x), where Y is dependent variable andX is independent variable.

In this case Y ( Dependent variable) is Perfomance in test, an it depends on x(Independent variable) wich is temperature.

7 0
3 years ago
What is the difference between ‘’ and “” string type in python?
Mekhanik [1.2K]

Answer:

There is no difference between ‘’ and “” string type in python. Both are used to hold the string or sequence of character in the python. triple """ """ can also use for the same.

Example:

str1 = "aeiou"

str2 = 'aeiou'

str3 =""" hello"""

print(type(str1), type(str2),type(str3))

<class 'str'> <class 'str'> <class 'str'>

Here all are used to hold string or sequence of character.

6 0
3 years ago
Other questions:
  • When pasting an object which has been copied from a different slide, where on the slide does the object paste, assuming nothing
    15·1 answer
  • Random-access memory (RAM) is able to quickly access data because it is arranged in which of the following configurations?
    8·2 answers
  • Who is president is US
    5·1 answer
  • What is a series of instructions or commands that a computer follows used to create software
    9·1 answer
  • You have just finished writing a lengthy research paper and you are ready for formatting. You insert your paragraph headings and
    15·1 answer
  • Which of the following is software? : Monitor Mouse Windows Keyboard Printer
    13·1 answer
  • What is renewable energy
    13·2 answers
  • Which type of computer network ensures high quality​
    9·1 answer
  • What is the WiFi signal strength in different iPhone models?
    7·1 answer
  • To implement a small database, a database designer must know the "1" and the "M" sides of each relationship and whether the rela
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!