Returns the "ordinal indicator" of number, e.g. 'st' for 1 and 'rd' for 23, because we write them as "1st" and "23rd".
(number)
| 83 | |
| 84 | |
| 85 | def getOrdIndicator(number): |
| 86 | """Returns the "ordinal indicator" of number, e.g. 'st' for 1 and |
| 87 | 'rd' for 23, because we write them as "1st" and "23rd".""" |
| 88 | lastDigit = str(number)[-1] |
| 89 | |
| 90 | if len(str(number)) >= 2: |
| 91 | secondToLastDigit = str(number)[-2] |
| 92 | else: |
| 93 | secondToLastDigit = '' |
| 94 | |
| 95 | if secondToLastDigit + lastDigit == '11': |
| 96 | return 'th' |
| 97 | elif secondToLastDigit + lastDigit == '12': |
| 98 | return 'th' |
| 99 | elif secondToLastDigit + lastDigit == '13': |
| 100 | return 'th' |
| 101 | elif lastDigit == '1': |
| 102 | return 'st' |
| 103 | elif lastDigit == '2': |
| 104 | return 'nd' |
| 105 | elif lastDigit == '3': |
| 106 | return 'rd' |
| 107 | else: |
| 108 | return 'th' |
| 109 | |
| 110 | |
| 111 | def displayMap(playerx, playery, visitedIntersections): |