Question: In this question, you'll write a method that takes a list of numbers [0-9] and returns a corresponding list with the ordinal versions. That is,

In this question, you'll write a method that takes a list of numbers [0-9] and returns a corresponding list with the "ordinal" versions. That is, if you see a 1 in the list, you'll create a string "1st". If you see a 3, you'll create a string "3rd", and so on. One exception is when detecting the number 8 in the list, then your solution should include it in the output then terminate. For example, if you receive [2,1,4,3,4] as input, you should create a list of strings that looks like this: [ "2nd", "1st", "4th", "3rd", "4th" ]. 2] : Solution goes here def return_ordinals(numbers): out_list =[] \#\#\# BEGIN SOLUTION \#\#\# END SOLUTION return out_list 9 ]: inlist =[7,5,6,6,3,5,1,0,8,2,1] outlist = ["7th", "5th", "6th", "6th", "3rd", "5th", "1st", "0th", "8th", ] for y_true, y_pred in zip(outlist, return_ordinals(inlist)): assert y _true = y_pred.lower ()
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
