Answer the question
In order to leave comments, you need to log in
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)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question