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")
Dieser Code gibt den Preis für das Senden von Paketen an. Ich bekomme "IndexError: Liste Index außerhalb des Bereichs" für alle if-Anweisungen und ich weiß nicht, warum bitte helfen Sie mir. Danke im Voraus :).IndexError: Listenindex außerhalb des gültigen Bereichs (auf einem Array)
Dies ist der vollständige Code, aber Stack-Überlauf sagt, es ist zu viel Code und nicht genug Details, so werde ich nur diesen Absatz hinzufügen, um Platz hinzuzufügen, so dass ich den vollständigen Code hinzufügen kann wie Sie gefragt. Also, wie geht es euch? Wo seid ihr her? Wie alt seid ihr? Warum ist es immer noch zu wenig Text und zu viel Code ... UGH wann wird das vorbei sein?
Nun, normalerweise ist das (dums), weil ** der Index außerhalb des Bereichs liegt **. Wisst ihr sicher, dass der Wert von "i" zwischen "0" (inklusive) und "len (pracelLength)" liegt (exklusiv). –
können Sie Ihren vollständigen Code zusammen mit Iterationen (for-Schleife, while-Schleife) anzeigen. – shiva
atleast können Sie die Länge von Paketbreite, Paketlänge, Pakethöhe, Paketgewicht usw. angeben. – shiva