简体   繁体   中英

How do I sort two parameters The largest number should be displayed first, and then from the smallest to the largest

def funcSort(a = int(input()), b =  int(input()), c =  int(input()))
if a>b and a>c:
    print(a)
    print(sorted(b,c,sep="\n"))
elif b>c and b>a:
    print(b)
    print(sorted(a,c,sep="\n"))
elif c>a and c>b:
    print(a)
    print(sorted(b,a,sep="\n"))

if you sort them into a list, you can then take the last number from the list using [-1] (this will be the largest), followed by all the other numbers using [0: -1] (this excludes the last number)

x = sorted([a, b, c])
print([x[-1], *x[0:-1]])

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM