Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For a list of strings, filter out the strings that are odd in length and then reverse each of these strings and return the resulting

image text in transcribed
image text in transcribed
For a list of strings, filter out the strings that are odd in length and then reverse each of these strings and return the resulting list. You can reverse a string using: \[ \begin{array}{l} \text { str_one = "test" } \\ \text { print(str_one[::-1]) } \end{array} \] A function has brenen created for you that takes a string and returns a reversed string. You should update the function so that it returns the correct list. Copy the following into main.py to get started. def reverse_string(str_to_reverse): return str_to_reverse[::-1] def task_answer(string_list): "n" you should filter out odd length def reverse_string(str_to_reverse): return str_to_reverse[::-1] def task_answer(string_list): "n you should filter out odd length strings and reverse these here. return the result as a list "u" pass if __name__=="_-main_" : str_list = ["this", "IS", "a", "list", "of", "a", "few", "strings"] result = task_answer(str_list) print(result) \# should print ['a', 'a', 'wef', 'sgnirt_]

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

More Books

Students also viewed these Databases questions

Question

sharing of non-material benefits such as time and affection;

Answered: 1 week ago