ValueError: zu viele Werte zu entpacken (dürfte 2)

In der Python-tutorial Buch, das ich verwende, ich tippte ein Beispiel gegeben für gleichzeitige Zuordnung. Ich bekomme den oben genannten ValueError, wenn ich das Programm ausführen, und kann nicht herausfinden, warum.

Hier der code:

#avg2.py
#A simple program to average two exam scores
#Illustrates use of multiple input

def main():
    print("This program computes the average of two exam scores.")

    score1, score2 = input("Enter two scores separated by a comma: ")
    average = (int(score1) + int(score2)) / 2.0

    print("The average of the scores is:", average)

main()

Hier ist die Ausgabe.

>>> import avg2
This program computes the average of two exam scores.
Enter two scores separated by a comma: 69, 87
Traceback (most recent call last):
  File "<pyshell#4>", line 1, in <module>
    import avg2
  File "C:\Python34\avg2.py", line 13, in <module>
    main()
  File "C:\Python34\avg2.py", line 8, in main
    score1, score2 = input("Enter two scores separated by a comma: ")
ValueError: too many values to unpack (expected 2)
Mögliche Duplikate von python valueerror : zu viele Werte zu entpacken
Dies ist, weil Sie mit Python ist3 überprüfen Sie meine Antwort vielleicht hilft es Euch 🙂

InformationsquelleAutor Ziggy | 2014-06-10

Schreibe einen Kommentar