Junior — Senior
Filtering list elements into a dictionary by prefix
livecode
Task condition
Determine what output will be displayed on the screen. Make sure you understand how the dictionary comprehension with a condition and the startswith() method work.
fruit_list = ['apple', 'orange', 'lemon', 'pineapple', 'pear']
result_dict = {
i: f
for i, f in enumerate(fruit_list)
if f.startswith('p')
}
print(result_dict)