Posts at or above the bar

Write code · Basic · §8.1 Searching a sorted list

likes holds the number of likes on each of one person's posts, in ascending order. Several posts may have the same number of likes.

A "Popular" badge goes on posts whose likes reach a certain bar, and the candidate bars are collected in goals. Complete the function solution, which returns, for each bar in goals, the number of posts with at least that many likes, as a list in the same order as goals.

Function

solution(likes, goals)

Constraints

Examples

likesgoalsresult
[3, 8, 15, 22, 40][10, 20][3, 2]
[0, 5, 5, 9][6, 1][1, 3]

Starter code

def solution(likes, goals):
    answer = []
    return answer

Solve this problem in your browser

Python runs in your browser and checks your answer right away. Hints and the answer are on the problem page.