python sort three numbers from small to large

angryTom
Release: 2020-02-29 13:35:05
Original
26290 people have browsed it

python sort three numbers from small to large

Python three numbers are sorted from small to large

1. First define a function paiLie(); then within the paiLie function Use a for loop and input to get three numbers and store them in the list; finally call the sort() method of the list to sort.

def paiLie():
    result = []
    for i in range(3):
        x = input("请输入数字:")
        result.append(x)
    result.sort()
    print result
Copy after login

2, Calling

paiLie()
请输入数字:56
请输入数字:5
请输入数字:89
Copy after login

Running result:

[5, 56, 89]
Copy after login

numerouspython Video tutorial , all on the PHP Chinese website, welcome to learn online!

The above is the detailed content of python sort three numbers from small to large. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!