Python-too many values to unpack(csv file)

I am trying all the countries with a life expectancy greater than 75 from a csv file in the latest python but I keep getting the error:

ValueError: too many values to unpack (expected 2)

The specific section it says is wrong is:

Name,LifeExpectancy=line.rstrip().split(',')

the full code is:


fo = open ('country.csv', 'r')

line=fo.readline()
while line:
    Name,LifeExpectancy=line.rstrip().split(',')
    if LifeExpectancy !='NULL' and LifeExpectancy >='75.0':
        print(Name,LifeExpectancy)
        line=fo.readline()

fo.close
    

does anyone know how to solve this?


split() method of string returns list. First check how many values do the list have:

list_with_splits = line.rstrip().split(',')
print(len(list_with_splits))

It probably has more than two elements.