Python ValueError: too many values to unpack
You need to split on the comma:
score1,score2 = input ("Enter two scores separated by a comma:").split(",")
Note however that score1
and score2
will still be strings. You will need to convert them into numbers using either float
or int
(depending on what number type you want).
See an example:
>>> score1,score2 = input("Enter two scores separated by a comma:").split(",")
Enter two scores separated by a comma:1,2
>>> score1
'1'
>>> score1 = int(score1)
>>> score1
1
>>> score1 = float(score1)
>>> score1
1.0
>>>
- You need to split the input you receive, because it arrives all in one string
- Then, you'll need to convert them to numbers, because the term
score1 + score2
will do string addition otherwise and you will get an error.