Question
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started