我正在嘗試編寫一個程序,要求用戶輸入一系列數字。一旦輸入數字,他們應該從大到小排序。這是我到目前爲止,我有點麻煩,搞清楚如何我可以訂購用戶已經投入的數字。我很確定應該使用一個do-while循環,我試圖找出如何執行它。另外,用戶應該輸入-99來結束一系列數字。Python 3從最大到最小的循環
//Define main function
def main():
numbers()
loop()
//Get user input
def numbers():
a=input()
b=input()
c=input()
d=input()
e=input()
number1=int(a)
number2=int(b)
number3=int(c)
number4=int(d)
number5=int(e)
//Define loop function
def loop():
//Call main function
main()
[Arrays](http://docs.python.org/2/library/array.html)肯定會癢癢你的泡菜。 – Bucket
@DesertIvy數組對於初學者來說是矯枉過正的,只是使用一個普通的列表! –
您可以在[list](http://docs.python.org/2/library/stdtypes。)上使用[sorted](http://docs.python.org/2/library/functions.html#sorted)。 HTML#可變序列類型)。你不想編寫你自己的循環來排序......其他人已經爲你完成了這項工作。 – SethMMorton