Login and get codingIn this Bite you complete a function that takes an
int
and returns it appended with the right suffix: 1 -> 1st, 2 -> 2nd, 4 -> 4th, 11 -> 11th, etc.As per Wikipedia the rules are:
- -st is used with numbers ending in 1 (e.g. 1st, pronounced first)
- -nd is used with numbers ending in 2 (e.g. 92nd, pronounced ninety-second)
- -rd is used with numbers ending in 3 (e.g. 33rd, pronounced thirty-third). As an exception to the above rules, all the "teen" numbers ending with 11, 12 or 13 use -th (e.g. 11th, pronounced eleventh, 112th, pronounced one hundred [and] twelfth)
- -th is used for all other numbers (e.g. 9th, pronounced ninth).
To focus on the exercise you can assume that the number inputted into the function is a positive
int
. Good luck and keep calm and code in Python!
140 out of 140 users completed this Bite.
Will you be the 141st person to crack this Bite?
Resolution time: ~29 min. (avg. submissions of 5-240 min.)
Our community rates this Bite 2.0 on a 1-10 difficulty scale.
» You can do it! 😌