问题遇到的现象和发生背景
【问题描述】输入若干成绩值,以回车作为输入结束。输出最高的三个成绩值,以及最大值和最小值。
【输入形式】"Input a score(end of enter):"
【输出形式】"Top 3 scores:" "max={},min={}"
【输入输出示例】
Input a score(end of enter):9Input a score(end of enter):4.6Input a score(end of enter):8.2Input a score(end of enter):1Input a score(end of enter):4Input a score(end of enter):7Input a score(end of enter):Top 3 scores:98.27max=9,min=1
ls=[]while True: n=input("Input a score(end of enter):") ls.append(n) if n=="": breakprint(sorted(ls,reverse=True)[0])print(sorted(ls,reverse=True)[0])print(sorted(ls,reverse=True)[0])print("max={},min={}".format(max(ls),min(ls)))谢谢谢谢谢,非常感谢