Question: a-c please Python Problem 1. Below you will find several codes that build lists. Rewrite these codes using list comprehensions. Subproblem A. No list comprehension:


a-c please
Python
Problem 1. Below you will find several codes that build lists. Rewrite these codes using list comprehensions. Subproblem A. No list comprehension: In [27]: words = ["apple", "banana", "kiwi", "orange"] masked_words =[] for w in words: masked_words.append("UNK") print(masked_word5) ['UNK', 'UNK', 'UNK', 'UNK'] List comprehension: In [ ] : \# your code Subproblem B. No list comprehension: In [ ]: \( \begin{array}{l}\text { names = ["andrew", "Mary", "jimmy", "Noam"] } \\ \text { title_names =[] } \\ \text { for name in names: } \\ \text { if name.istitle(): } \\ \text { title_names.append (name) } \\ \text { print(title_names) }\end{array} \) List comprehension: In [ ] : \# your code Subproblem C. No list comprehension: List comprenension: In [ ] : \# your code
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
