Task:
- Write a function `index` that converts an int from 0 to 5 into its word. (It should take an int and return a string.)
0 -> "zero"
1 -> "one"
2 -> "two"
3 -> "three"
4 -> "four"
5 -> "five"
anything else -> "other"
One thing to note is that you have a dangling else-if - that is, you don't have a final "else" condition to catch a situation where none of the previous conditions is met. You might want to add something like:
1 2
elsereturn"invalid number ";
Or maybe construct a string which states what the number actually is, for debugging purposes, and return that.