First, the basic Python Tutorial 2nd Board (revision) "Code listing 2-1" There is a requirement to print ' 1-31 number as the end of the list '
Intercept code example:endings =[' st ', ' nd ', ' Rd '] +17*[' th '] + [' st ', ' nd ', ' Rd '] +7*[' th '] +[' st ']
Operation Result: Print (endings)
[' st ', ' nd ', ' rd ', ' th ', ' th ', ' th ', ' th ', ' th ', ' th ', ' th ', ' th ', ' th ', ' th ', ' th ', ' th ', ' th ', ' th ', ' th ', ' th ', ' th ', ' St ', ' nd ', ' rd ', ' th ', ' th ', ' th ', ' th ', ' th ', ' th ', ' th ', ' st '
Note: The above test results are completed in Pycharm
Second, the first doubts why the list can be written like that? A little to figure out and Baidu, the original is the English 1-31 days of the end of the English character shorthand, of which 1-31 days of the English comparison is as follows:
First (1st)
Second (2nd)
Third (3rd)
Fourth (4th)
Fifth (5th)
Sixth (6th)
Seventh (7th)
Eighth (8th)
Ninth (9th)
Tenth (10th)
Eleventh (11th)
Twelfth (12th)
Thirteenth (13th)
Fourteenth (14th)
Fifteenth (15th)
Sixteenth (16th)
Seventeenth (17th)
Eighteenth (18th)
Nineteenth (19th)
Twentith (20th)
Twenty-first (21st)
Twenty-second (22nd)
Twenty-third (23rd)
Twenty-fourth (24th)
Twenty-fifth (25th)
Twenty-sixth (26th)
Twenty-seventh (27th)
Twenty-eighth (28th)
Twenty-ninth (29th)
Thirtith (30th)
Thirty-first (31st)
Thirdly, it can be seen that the importance of English in daily coding and learning, adhere to the process of coding to insist on learning english!
python--with a 1-31 number as the ending list? On the importance of good English!