Ad
Fundamentals
Code
Diff
  • class OrdinalNumbers:
        def __init__(self, n):
            self.n = n
            
        def solution(self):
            if (self.n>10) and (self.n<20): return (str(self.n)+"th")
            elif (str(self.n)[-1]=="1"): return (str(self.n)+"st")
            elif (str(self.n)[-1]=="2"): return (str(self.n)+"nd")
            elif (str(self.n)[-1]=="3"): return (str(self.n)+"rd")
            else: return (str(self.n)+"th")
    • class OrdinalNumbers:
    • def __init__(self, n):
    • self.n = n
    • def solution(self):
    • pass
    • if (self.n>10) and (self.n<20): return (str(self.n)+"th")
    • elif (str(self.n)[-1]=="1"): return (str(self.n)+"st")
    • elif (str(self.n)[-1]=="2"): return (str(self.n)+"nd")
    • elif (str(self.n)[-1]=="3"): return (str(self.n)+"rd")
    • else: return (str(self.n)+"th")