Python - List of Files: Functions, Modules and Files - multiple assignment, unpacking technology
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 & Files)、EXERCISE(219/682)の解答を求めてみる。
Jupyter(コード、入出力結果)
Files.ipynb
import swimclub
data = swimclub.read_swim_data('Darius-13-100m-Fly.txt')
data
('Darius',
'13',
'100m',
'Fly',
['1:27.95', '1:21.07', '1:30.96', '1:23.22', '1:27.95', '1:28.30'],
'1:26.58')
times = data[4]
times
['1:27.95', '1:21.07', '1:30.96', '1:23.22', '1:27.95', '1:28.30']
swimmer, age, distance, stroke, times2, average = data
swimmer
'Darius'
age
'13'
distance
'100m'
stroke
'Fly'
times2
['1:27.95', '1:21.07', '1:30.96', '1:23.22', '1:27.95', '1:28.30']
average
'1:26.58'