Write a function called filter_even_string that takes one parameter: a list and
ID: 3858001 • Letter: W
Question
Write a function called filter_even_string that takes one parameter: a list and returns a list of all strings of even length in the original list. You may NOT assume that everything in the list is a string. Items in the new list must be in the same order as in the original list.
Write a function called filter even string that takes one parameter: a list and returns a list of all strings of even length in the original list. You may NOT assume that everything in the list is a string. Items in the new list must be in the same order as in the original list. For example Result Test print(filter_even_string(t"",1,2,3,"hi"))hi'l print(filter_even_string(l1,2,3,"the")) Answer: CheckExplanation / Answer
def filter_even_string(list): result = [] for i in list: try: str = int(i) except ValueError: if len(i) % 2 == 0: result.append(i) return result list = input().split(",") print(filter_even_string(list))
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.