Python - List of Files: Functions, Modules and Files - ValueError
Head First Python: A Learner’s Guide to the Fundamentals of Python Programming, A Brain-Friendly Guide、 Paul Barry(著)、 O’Reilly Mediaの Chapter 4.(List of Files: Functions, Modules and Files)、EXERCISE(229/682)の解答を求めてみる。
Jupyter(コード、入出力結果)
Times.ipynb
for filename in swim_files:
print(filename)
swimclub.read_swim_data(filename)
Hannah-13-100m-Free.txt
Darius-13-100m-Back.txt
Owen-15-100m-Free.txt
Mike-15-100m-Free.txt
Hannah-13-100m-Back.txt
Mike-15-100m-Back.txt
Mike-15-100m-Fly.txt
Abi-10-50m-Back.txt
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In[15], line 3
1 for filename in swim_files:
2 print(filename)
----> 3 swimclub.read_swim_data(filename)
File ~/posts/cs/head-first-python/ch4/swimclub.py:14, in read_swim_data(filename)
12 converts = []
13 for t in times:
---> 14 minutes, rest = t.split(':')
15 seconds, hundredths = rest.split('.')
16 converts.append(
17 int(minutes) * 60 * 100 + int(seconds) * 100 + int(hundredths)
18 )
ValueError: not enough values to unpack (expected 2, got 1)