Answered step by step
Verified Expert Solution
Link Copied!

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 26 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.ascii_lowercase.
For the remainder of the program, we will use this code exactly:
print(alphabet)
print(reverse_a_list(alphabet))
print(alphabet)
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 "reverse_a_list(my_list)"
Here are the requirements for reverse_a_list(my_list)
The first line of the function should be print(f"The length of my_list is now: {len(my_list)}"). 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 my_list is 1
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

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

Oracle RMAN For Absolute Beginners

Authors: Darl Kuhn

1st Edition

1484207637, 9781484207635

More Books

Students also viewed these Databases questions

Question

How do you see the company changing over the next 5 years?

Answered: 1 week ago

Question

What different skills and behaviours will be needed?

Answered: 1 week ago