The [0] * x
creates a list with x
elements. So,
>>> [ 0 ] * 5
[0, 0, 0, 0, 0]
>>>
Be warned that they all point to the same object. This is cool for immutables like integers but a pain for things like lists.
>>> t = [[]] * 5
>>> t
[[], [], [], [], []]
>>> t[0].append(5)
>>> t
[[5], [5], [5], [5], [5]]
>>>
The **
operator is used for exponentation.
>>> 5 ** 2
25
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…