2014年2月16日日曜日

開発環境

Learning Python (Mark Lutz (著)、Oreilly & Associates Inc)のPART II.(Types and Operations)、Test Your Knowledge: Part II Exercises、2-a, b, c(Indexing and slicing)を解いてみる。

その他参考書籍

2-a, b, c(Indexing and slicing)

入出力結果(Terminal)

$ python3
Python 3.3.4 (default, Feb 10 2014, 22:06:52) 
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.2.79)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> l=[0, 1, 2, 3]
>>> l[4] # エラー
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
IndexError: list index out of range
>>> l[-1000:100] # [0, 1, 2, 3]
[0, 1, 2, 3]
>>> l[3:1] # []
[]
>>> l[3:1] = ['?']
>>> l # [0, 1, 2, '?', 3]
[0, 1, 2, '?', 3]
>>> quit()
$

0 コメント:

コメントを投稿