print("NOTE: Parcels can only be smaller than 100x100x100cm (WxLxH) and weight less than 20kg")
parcelAmount = int(input("How many parcels are you sending?: "))
for i in range(parcelAmount):
parcelWidth.append(input("Please enter the width of the parcel " + str(i + 1) + ": "))
parcelLength.append(input("Please enter the length of the parcel " + str(i + 1) + ": "))
parcelHeight.append(input("Please enter the height of the parcel " + str(i + 1) + ": "))
parcelWeight.append(input("please enter the weight of the parcel " + str(i + 1) + ": "))
i = i + 1
if float(parcelWidth[i]) or float(parcelLength[i]) or float(parcelHeight[i]) > int(100) or float(parcelWeight[i]) > int(20):
parcelRej = parcelRej + 1
parcelAcc = parcelAmount - parcelRej
if float(parcelWeight[i]) > 1 and float(parcelWeight[i]) < 5:
parcelPrice[i] = 10
if float(parcelWeight[i]) > 5:
parcelPrice[i] = parcelWeight[i] - 5 + 10
print("There are " + str(parcelRej) + " parcels rejected")
print("There are " + str(parcelAcc) + " parcels accepted")
print("It will cost $" + str(sum(parcelPrice)) + " To ship the parcel")
このコードは、パーセルを送信する価格を検出します。私は "IndexError:リストのインデックスを範囲外に"取得し続けます。なぜなら、私はなぜ私を助けてくれるのかわかりません。前もって感謝します :)。IndexError:リストのインデックスが範囲外(リスト上)
これは完全なコードですが、スタックオーバーフローはあまりにも多くのコードであり、詳細が不十分だと言っていますので、スペースを追加するためにこの段落を追加します。あなたはどうやってやっていますか?あなたはどこから来たの?君たち歳いくつ?なぜそれはまだ小さすぎるテキストとあまりにも多くのコードです... UGHこれはいつ終わるでしょうか?
インデックスは範囲外です**ので、通常(ダム)です。 'i'の値が' 0'(両端を含む)と 'len(pracelLength)'(排他的)の間にあることをあなたは知っていますか? –
あなたは完全なコードを反復とともに表示できます(for-loop、whileループ)。 – shiva
少なくともparcelWidth、parcelLength、parcelHeight、parcelWeight ..の長さを指定できます。 – shiva