Ładowanie zadania…
Grouping helps you sort data into simple, useful buckets. The function group_by_parity receives a list of numbers nums and separates them into even and odd numbers. Return a dictionary with the keys even and odd, and keep the numbers inside each list in their original order of appearance.
[1, 2, 3, 4]{"even": [2, 4], "odd": [1, 3]}[]{"even": [], "odd": []}[2, 4, 6]{"even": [2, 4, 6], "odd": []}def group_by_parity(nums: list[int]) -> dict:
Zaloguj się, aby zobaczyć historię rozwiązań
Zaloguj sięZaloguj się, aby korzystać z Mentora AI
Zaloguj sięThey run when you press "Submit" — your whole solution is checked against them so you can't hard-code answers for the visible cases.