Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

Python programming

Ask the user to input two lists. list which interleaves the two lists by taking 1 from the first list and then 1 from the second list. Output the interleaved list. If the either list is longer than the other append the remaining elements from it at the end.

Sample output1:

Please enter list 1: 1 5 10 20

Please enter list 2: 3 9 11 22

The combined list is 1 3 5 9 10 11 20 22

Sample output2:

Please enter list 1: 1 22 2 1 7

Please enter list 2: 11 33

The combined list is 1 11 22 33 2 1 7

Sample output3:

Please enter list 1: 1 2 4 8

Please enter list 2: 13 3 5 9 10 11

The combined list is 1 13 2 3 4 5 8 9 10 11

inp = input("Please enter list 1: ")

inp2 = input("Please enter list 2: ")

ls1 = [int(x) for x in inp.split()]

ls2 = [int(x) for x in inp2.split()]

ans = []

for i in range(len(ls1)):

   ans.append(ls1[-1-i])

   ans.append(ls2[i])

print("The combined list is", end = " ")

for i in ans:

   print(i,end = ' ')

What should I change?

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M92800788
  • Price:- $10

Priced at Now at $10, Verified Solution

Have any Question?


Related Questions in Computer Engineering

Question the use of encryption can have adverse effects on

Question: The use of encryption can have adverse effects on incident response and incident investigations; however, from a security standpoint, encryption is a major component in network confidentiality. Present your arg ...

What are information silos what are the problems caused by

What are information silos? What are the problems caused by information silos? How organizations can solve the problems caused by information silos?

Explain that our ability to secure each computers stored

Explain that our ability to secure each computers stored information is now influenced by the security on each computer to which it is connected

Question 1 emergency operations- a major hurricane has

Question 1: Emergency operations - A major hurricane has struck the area where your company has its central data center. There are offsite backups and hardware at three other centers around the country. - Assume that the ...

Need help with the following 2 problems1 they offer you a

Need help with the following 2 problems: 1. They offer you a promissory note with a four-year maturity, which will generate $ 3,000 at the end of each of the four years. Its price is $ 10,200. What is the implicit annual ...

The inflation rate is 20 per year the real rate of return

The inflation rate is 2.0% per year. The real rate of return is 2.5% per year. A perpetuity that paid $100 this year will provide income that grows by the inflation rate. What is the value of the perpetuity?

Suppose users share a 2 mbps link also suppose each user

Suppose users share a 2 Mbps link. Also suppose each user transmits continuously at 1 Mbps when transmitting, but each user transmits only 20 percent of the time. When a circuit switching is used, how many users can be s ...

The solution of this exercise please 37 creating an

The solution of this exercise please: 3.7 (Creating an Autocomplete Form) Create a simple search form using a search input element in which the user can enter a search query. Using the Firefox web browser, test the form ...

Suppose in your company you formulate a python script that

Suppose in your company you formulate a Python script that inserts, updates, and deletes data in tables in a MySQL database. You post your Python script on a shared drive for other staff members to use. What are some the ...

What is the role of arp and how does it cause a security

What is the role of ARP and how does it cause a security concern? What is the different between global and private IP addresses? How does using NAT change a private IP address into a global IP address, and why is this so ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As