D
D
DavidDavidrrrr2021-06-20 20:08:57
Python
DavidDavidrrrr, 2021-06-20 20:08:57

Why does this error occur and how can I fix this code?

f=open('/storage/emulated/10/bl/y.txt','r')
file=str(f.read())
print(file)
id, name = map(list, zip(file))
print(id, name)


Here is the error
[1837769803, 'Tt'],[1837765893, 'Tp'],[1837765803, 'ot'],[1837465803, 'g']

Traceback (most recent call last):
File "/data/user/10/ en.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 31, in
start(fakepyfile,mainpyfile)
File "/data/user/10/en.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run. py", line 30, in start
exec(open(mainpyfile).read(), __main__.__dict__)
File "", line 4, in
ValueError: too many values ​​to unpack (expected 2)

[Program finished]

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dmshar, 2021-06-20
@dmshar

I'll repeat the question here, since there is no answer:
What did you want to do with this operator.
id, name = map(list, zip(file))
Obviously, map creates many more objects than the fields you show on the left.
In general - wrap your code in the appropriate tag in the question. This is not your first question on the forum, for this they can already be punished.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question