Question: Python Question: What's wrong with my code? Please provide a corrected code with loop. Thank you Objectives: Practice list manipulation with loop. . Write a

Python Question: What's wrong with my code? Please provide a corrected codewith loop. Thank you Objectives: Practice list manipulation with loop. . WritePython

Question: What's wrong with my code? Please provide a corrected code with loop. Thank you

Objectives: Practice list manipulation with loop. . Write a function, named start_p, that accepts a list of strings as argument and returns a new list that contains only those strings that start with letter p. You should write a loop to implement such a functionality. For example, the function call of start_p (["alpha", "beta", "gamma", "omega", "psi", "lamda", "epsilon", "phi"]) should return ['psi', 'phi'], and start_p(["apple", "", "pineapple", "kiwi", "pear", "pomegranate"]) should return ['pineapple', 'pear', 'pomegranate']. def start_p(terms): for word in terms: if word [0]=='p': return [word] def main(): greeks = ["alpha", "beta" "gamma", "omega", "psi", "lamda", "epsilon", "phi"] print(start_p(greeks)) fruits = ["apple", "pineapple", "kiwi", "pear", "pomegranate"] print(start_p(fruits)) main() Ln: 14 cc vvvvyvoorry ['psi'] ['pineapple'] >>>

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!