Course of Raku / Essentials / Positional data types / Exercises

Odd indices

Problem

You have a array of numbers:

my @data = 10, 12, 1, 5, -9, 8, 36, 18, 21;

Complete the program to print only the elements with odd indices. Make sure the program still works if you change the number of items in @data.

Example

$ raku odd-indices.raku
12
5
8
18

Solution

See the solution

Next exercise

💪 Print a series of numbers

Course navigation

Typed variables / Allomorphs   |   Associative data types