Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Given a list of integers from 1~9, write code to create a series of new lists, such that each new list will include one digit

Given a list of integers from 1~9, write code to create a series of new lists, such that each new list will include one digit from the original list, repeated for a number of times as indicated by the number itself. For example, assuming a list as following: [9, 6, 4, 7, 8, 2, 5], the output lists will look as the following:

Part a) Expected output:

999999999 666666 4444 7777777 88888888 22 55555

Noted that your program should be applicable when the data inside ls changes (but are still in valid range and format).

ls = [9, 6, 4, 7, 8, 2, 5]

# Start your code below # Part a

Part b) Expected output:

[9, 9, 9, 9, 9, 9, 9, 9, 9] [6, 6, 6, 6, 6, 6] [4, 4, 4, 4] [7, 7, 7, 7, 7, 7, 7] [8, 8, 8, 8, 8, 8, 8, 8] [2, 2] [5, 5, 5, 5, 5]

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Refactoring Databases Evolutionary Database Design

Authors: Scott Ambler, Pramod Sadalage

1st Edition

0321774515, 978-0321774514

More Books

Students also viewed these Databases questions

Question

=+3. What staffing challenges arise from this situation?

Answered: 1 week ago