I run this code:
def score(string, dic):
for string in dic:
word,score,std = string.lower().split()
dic[word]=float(score),float(std)
v = sum(dic[word] for word in string)
return float(v)/len(string)
And get this error:
word,score,std = string.split()
ValueError: need more than 1 value to unpack
It’s because
string.lower().split()is returning a list with only one item. You cannot assign this toword,score,stdunless this list has exactly 3 members; i.e.stringcontains exactly 2 spaces.