Course of Raku / Addendum 🆕 / Working with data / Lists, arrays, and hashes / Exercises

Zip two lists into a hash

Problem

You have two parallel lists: names <Anna Bob Cara> and scores 90, 85, 95. Combine them into a hash mapping each name to its score, and print each entry as name: score, ordered by name.

Example

The program prints:

Anna: 90
Bob: 85
Cara: 95

Solution

See the solution

Course navigation

Solution: The most common element   |   Solution: Zip two lists into a hash