Append the remaining elements from it at the end

Assignment Help Basic Computer Science
Reference no: EM131963131

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?

Reference no: EM131963131

Questions Cloud

Prepare a summary report of the scholarly activity : Prepare a summary report of the scholarly activity, including who, what, where, when and any relevant take-home points.
Write review on the given article : Write 500-600 words review on the following article: Article: Employee reactions to talent pool membership (Author(s): Stephen Swailes and Michelle Blackburn)
Investment worth-amount of the special payment : Zach has an investment worth 63,726 dollars. What is X, the amount of the special payment that will be made to Zach in 4 quarters?
Describe what happened for the organisations stakeholders : Describe briefly what happened, the context, and the consequences for the organisation's stakeholders.
Append the remaining elements from it at the end : Output the interleaved list. If the either list is longer than the other append the remaining elements from it at the end.
What is the value of investment : What is the value of an investment that will pay investors 2,270 dollars per year for 7 years
What is the payment expected to be in one month : The interest rate on the loan is 1.15 percent per month. What is the payment expected to be in 1 month?
Reflect on the personal knowledge and skills gained : In your journal, you will reflect on the personal knowledge and skills gained throughout this course. Solid academic writing is expected, and in-text citations.
Questions should be asked regarding the computer system : What can be done to restore these deleted files and what questions should be asked regarding the computer system?

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Identifies the cost of computer

identifies the cost of computer components to configure a computer system (including all peripheral devices where needed) for use in one of the following four situations:

  Input devices

Compare how the gestures data is generated and represented for interpretation in each of the following input devices. In your comparison, consider the data formats (radio waves, electrical signal, sound, etc.), device drivers, operating systems suppo..

  Cores on computer systems

Assignment : Cores on Computer Systems:  Differentiate between multiprocessor systems and many-core systems in terms of power efficiency, cost benefit analysis, instructions processing efficiency, and packaging form factors.

  Prepare an annual budget in an excel spreadsheet

Prepare working solutions in Excel that will manage the annual budget

  Write a research paper in relation to a software design

Research paper in relation to a Software Design related topic

  Describe the forest, domain, ou, and trust configuration

Describe the forest, domain, OU, and trust configuration for Bluesky. Include a chart or diagram of the current configuration. Currently Bluesky has a single domain and default OU structure.

  Construct a truth table for the boolean expression

Construct a truth table for the Boolean expressions ABC + A'B'C' ABC + AB'C' + A'B'C' A(BC' + B'C)

  Evaluate the cost of materials

Evaluate the cost of materials

  The marie simulator

Depending on how comfortable you are with using the MARIE simulator after reading

  What is the main advantage of using master pages

What is the main advantage of using master pages. Explain the purpose and advantage of using styles.

  Describe the three fundamental models of distributed systems

Explain the two approaches to packet delivery by the network layer in Distributed Systems. Describe the three fundamental models of Distributed Systems

  Distinguish between caching and buffering

Distinguish between caching and buffering The failure model defines the ways in which failure may occur in order to provide an understanding of the effects of failure. Give one type of failure with a brief description of the failure

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd