Course of Raku / Essentials / Associative data types / Exercises
Seen before?
Problem
Create a program that starts a loop with the following actions:
- Ask to enter a word.
- If the word has been seen once already, print
Seen!
. - If the word has been seen more than once, print
Seen 2 times!
, etc. - Repeat the loop.
Example
An example of interaction with the program:
$ raku seen-before.raku
Word: I
Word: never
Word: saw
Word: a
Word: saw
Seen!
Word: that
Word: saw
Seen 2 times!
True
Word: as
Word: that
Seen!
Word: saw
Seen 3 times!
True
Word: sawed
Word: ^C
To stop the program, press Ctrl+C
.
Solution
Next exercise
Course navigation
← Positional data types / Subscripting ranges | Creating and calling functions →
Translations of this page: English • Deutsch • Español • Italiano • Latviešu • Nederlands • Български • Русский • Українська