Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In main ( ) , use a list comprehension to create a list object called alphabet, it is an alphabetical list of the 2 6
In main use a list comprehension to create a list object called "alphabet", it is an alphabetical list of the lowercase letters of the English alphabet, each letter of the alphabet will be a separate item in the list. No cheating, you must construct it using a list comprehension and it will take exactly one line of code. You should construct the list comprehension using chr as in the modules, or you can explore the string package and use string.asciilowercase.
For the remainder of the program, we will use this code exactly:
printalphabet
printreversealistalphabet
printalphabet
And the result should be the alphabet printed forward as a list then backward reverse order then forward again.
Of course, this will not work until you implement the function "reversealistmylist
Here are the requirements for reversealistmylist
The first line of the function should be printfThe length of mylist is now: lenmylist USUALLY we don't want to have a function like this output anything, but this will just help you and I evaluate whether the function is doing what it is supposed to do
The function must call itself with a smaller list until the length of mylist is
The function should return a new list in reverse order, leaving the original list in its original order
To be most elegant, your function needs to use some slicing and some list concatenation
The recursion should not be trivial. That is each function should rely on the next level of recursion to help it construct the reversed list. It is not sufficient to use a list method or a slice reversal to solve this assignment.
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