Q
Q
qwwwwwty2021-10-29 18:11:47
Python
qwwwwwty, 2021-10-29 18:11:47

What is the error and how to fix it, Python?

it is necessary that the python read 2 .txt files that are in the same directory (their names are txt A.txt, txt B.txt). when trying to read txt B.txt, an error pops up:

not enough values ​​to unpack (expected 2, got 1)

here is my code:

ares = {}

a = open('txt A.txt', 'r')
for line in a.readlines():
    name,score = line.split(",")
    ares[name] = int(score)

bres = {}

b = open('txt B.txt', 'r')
for line in b.readlines():
    name,score = line.split(",")
    bres[name] = int(score)


PS I already tried to change the variables in the b code itself, but still the error is still the same.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question