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
Explain what a wiki is and list its advantages.
Drupady [299]

Explanation:

Wikis are defined as a form of a website or web page or a database where the users can work on the data, they can even add or edit the data. Wikis use a very quick as well as a easy syntax that allows the users to format the text and create various links between the pages. The users need internet browsers for that.

One of the main advantage of wiki is that it provides ability to collaborate asynchronously, and also without  time constraints.Besides it also provides a beneficial function of something. It is free and not expensive.

5 0
3 years ago
An excel workbook can exist without any worksheet, true or false​
mihalych1998 [28]

False

Explanation:

Its False because every book has worsheet

6 0
3 years ago
What educational site could I make a screen capture tutorial on? I need ideas for a school project.
snow_tiger [21]

You Need Software To Screen Capture

The Software You can use is OBS its free and there are watermarks

4 0
3 years ago
To drive defensively, you should _______________.
Keith_Richards [23]
The answer is B, look ahead and keep your eyes moving
7 0
3 years ago
Which two statements are true regarding the user exec mode? (choose two.)?
likoan [24]
<span>Global configuration mode can be accessed by entering the enable command.</span><span>
The device prompt for this mode ends with the ">" symbol.</span>
8 0
4 years ago
Other questions:
  • What is another way to use the Help feature in Access 2016?
    15·2 answers
  • Based on your learning this week, consider rules, policies, and procedures. Technicians are often eager to just get started on a
    10·1 answer
  • Polygon transform (25 points). Write a library of static methods that performs various geometric transforms on polygons. Mathema
    12·1 answer
  • Suppose an application generates chunks of 20 bytes of data every 20 msec, and each chunk gets encapsulated in a TCP segment and
    14·1 answer
  • Select the correct navigational path to create the function syntax to use the IF function.
    13·2 answers
  • 2×2×2×2×2×2×2×2:-) :-) :-) :-) :-) :-) :-! ​
    11·2 answers
  • What tag would you enter to link the text “White House" to the URL<br> http://www.whitehouse.gov?*
    15·1 answer
  • Write a function that takes a list and returns its first element​
    15·1 answer
  • Submitting Unit 11 Assignment – Step 1 Python CS Fundamentals<br> Need the code to this.
    8·1 answer
  • confidentiality ensures that only those with the rights and privileges to access information are able to do so.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!