python--with a 1-31 number as the ending list? On the importance of good English!

Source: Internet
Author: User

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!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.