Python exercises 027: Sort 10 numbers

Source: Internet
Author: User

"python exercise 027" to sort 10 numbers


There is nothing to say, use Str.split (") to get the input 10 numbers, and then use the Lst.sort () to complete the sorting. The code is as follows:

s = input (' Please enter 10 digits separated by a space: ') n = [int (x) for x in S.split (")]n.sort () print (n)

The output results are as follows:

Please enter 10 digits separated by a space: 3 23 4 64 6 17 80 212 9 132
[3, 4, 6, 9, 17, 23, 64, 80, 132, 212]


Source: Programming Language Introduction Classic 100 Cases "Python Edition"

Python exercises 027: Sort 10 numbers

Related Article

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: 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.