Next in the Queue

Python FundamentalsEasy+10 XP+10

Next in the Queue

A bakery calls customers in order. The list queue starts with the person who has waited longest.

Task: write next_up(queue, how_many) that returns a list of the first how_many people in the queue, in order.

  • how_many is always between 0 and the number of people in the queue. If it's 0, return an empty list.

Examples

queue = ["Ana", "Ben", "Cy", "Dee"]
how_many = 2
returns ['Ana', 'Ben']
queue = ["Ana", "Ben", "Cy", "Dee"]
how_many = 3
returns ['Ana', 'Ben', 'Cy']

Hints

Solve it to unlock the solution

Once your code passes every test, a reference solution shows up here so you can compare it with yours.

solution.py
CtrlEnterto run