1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Python > Comprehension > cells > 2重の内包表記 / itertoolsを使う方法を教えていただきました

Last updated at Posted at 2017-03-23

@ Introducing Python: Modern Computing in Simple Packages by Bill Lubanovic
(No. 2351 / 12833)

内包表記を使って、表を作る例が掲載されている。

rows = range(1,4)
cols = range(1,3)
cells = [(row, col) for row in rows for col in cols]
for cell in cells:
	print(cell)
結果
Success	time: 0 memory: 23968 signal:0
(1, 1)
(1, 2)
(2, 1)
(2, 2)
(3, 1)
(3, 2)

教えていただいた事項

(追記 2017/03/24)

@shiracamus さんのコメントにおいて、itertools使用の方法を教えていただきました。

情報感謝です。

1
0
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?