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
2, Calling
paiLie() 请输入数字:56 请输入数字:5 请输入数字:89
Running result:
[5, 56, 89]
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!