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
Vinvika [58]
3 years ago
10

Given the lists list1 and list2, not necessarily of the same length, create a new list consisting of alternating elements of lis

t1 and list2 (that is, the first element of list1 followed by the first element of list2 , followed by the second element of list1, followed by the second element of list2, and so on. Once the end of either list is reached, the remaining elements of the longer list is added to the end of the new list. For example, if list1 contained [1, 2, 3] and list2 contained [4, 5, 6, 7, 8], then the new list should contain [1, 4, 2, 5, 3, 6, 7, 8]. Associate the new list with the variable list3.
Computers and Technology
1 answer:
tester [92]3 years ago
5 0

Answer:

The following code is written in Python Programming Language.

Program:

list1=[1,2,3]

 # initialized the list type variable

list2=[4,5,6,7,8]

  # initialized the list type variable

list3=[]

   # initialized the empty list type variable

for j in range(max(len(list1), len(list2))):   #set for loop

 if j<len(list1):

  #set if statement

   list3.append(list1[j])

  #value of list1 appends in list3  

 if j<len(list2):

   #set if statement

   list3.append(list2[j])

  #value of list2 append in list3

print(list3)    #print the list of list3

Output:

[1, 4, 2, 5, 3, 6, 7, 8]

Explanation:

Here, we define three list type variables "list1", "list2", "list3" and we assign value in only first two variables "list1" to [1, 2, 3] and "list2" to [4, 5, 6, 7, 8] and third list is empty.

Then, we set the for loop and pass the condition inside it we pass two if conditions, in first one we compare the list1 from variable "j" inside it the value in list1 will append in list3, and in second one we compare "j" with list two and follow the same process.

After all, we print the list of the variable "list3".

You might be interested in
In a mission critical environment, performing maintenance operations on a host FIRST requires which of the following?
jonny [76]

Answer: (B) Migrating all VMs off the host.

Explanation:

  VMs migration is the virtual machine migration that basically change the workloads automatically in the system. The maintenance of the schedule results into the downtime in the server for users. In the mission critical environment, when we performing various types of maintenance operation on the host we first require migrate all the virtual machine.

 In the critical environment there is a chance that the data in the given host may be critical and the data in the virtual machine (VM) may be in critical position in the host.

5 0
3 years ago
What is the difference between the web and the internet?
Naddika [18.5K]
The Web is just one of the ways that information can be disseminated over the Internet
4 0
2 years ago
45 points!!
pav-90 [236]

Answer:

ENQUIRE database system

Explanation:

5 0
3 years ago
Read 2 more answers
Libby wrote an email to her friend. She pressed Shift and the number key 2 together to enter the email address. Which symbol did
exis [7]

When Libby wrote the email to her friend, she typed the '@' symbol. When pressing SHIFT and 2 together, it pastes this aforementioned symbol. However, there isn't any specific name for the symbol. As a matter as fact, there are several names that this symbol goes by.

The most famous name this symbol is called is the "at symbol" or the "at sign". In terms of a formal name, "commercial at" would be a good one.

Here's an example with the symbol:

[email protected]

This is essentially telling the email server where to send your email. From this, they'll know it's located at brainly.com! It's pretty neat.

4 0
3 years ago
Read 2 more answers
:P 80 points to spare so i guess its free!!!!!!
Naddik [55]

Answer:

Thank you! can i have brainliest please?

Explanation:

5 0
2 years ago
Read 2 more answers
Other questions:
  • The purpose of a capacitor unit in a vacuum cleaner is to
    12·1 answer
  • By applying styles formats are being applied ?
    14·2 answers
  • Plagiarism occurs when writers
    14·2 answers
  • A structure that specifies which of a number of permitted data types (e.g. integers) that may be stored in its instances is:
    6·1 answer
  • When using a file name you have to use only lower case letters<br>true or false
    11·1 answer
  • A speaker takes a variety of information from the results of a web search, and puts it together in an outline to make up his spe
    8·1 answer
  • Donna often travels around the world. When she travels, she needs to access her emails from different locations. However, to kee
    6·2 answers
  • Select the software which is used to convert audio data to text .
    15·1 answer
  • What is the working principle of computer?​
    10·1 answer
  • What would the input, process, outcome and feedback be for a class assignment
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!