私はしばらくの間これをやろうとしてきましたが、いつも違う失敗を抱えています。私は、ユーザーからの数値入力を取り、値を小さくして、リスト出力、それにそれを配置する必要があります:Pythonの数字のリストを逆に
bids = []
bid = input('Bid: ')
while bid != '':
bids.append(bid)
bid = input('Bid: ')
print('The auction has finished! The bids were:')
for bid in bids:
bid = int(bid)
for bid in reversed(bids):
print(bid)
だから、これはうまくほとんどの時間を働いていた、(私は数字2,3,4を使用しています入力として& 10が最初の数字のために順に番号を示し、ここで、私は問題を抱えてきたように)が、私は16、30、24に入力すると、それは、AS番号を表示します。
The auction has finished! The bids were:
24
30
16
ここで別のバージョンであります私は試みました:
bids = []
bid = input('Bid: ')
while bid != '':
bids.append(bid)
bid = input('Bid: ')
print('The auction has finished! The bids were:')
for bid in bids:
bid = int(bid)
bids.sort([::-1]) #Here is where the problem is at, I don't know
#what the correct syntax is for something like that
for bid in bids:
print(bid)
私はかなりPythonに新しいので、私のコースと苦労しているので、どんな助けも大歓迎です。
-Callum
このパイソン2やPython 3か? 'input'はそれぞれに非常に異なることを行います。 – ShadowRanger
私はpythonを信じています –
@CPastuszak 'python --version'を実行してください – Daenyth