height = 5
empty_pyramid = [['*'] * (height * 2)] * height
empty_pyramid2 = [['*','*','*','*','*','*','*','*','*','*'], ['*','*','*','*','*','*','*','*','*','*'],
['*','*','*','*','*','*','*','*','*','*'], ['*','*','*','*','*','*','*','*','*','*'],
['*','*','*','*','*','*','*','*','*','*']]
if empty_pyramid == empty_pyramid2:
print(True)
Both print True, but when put through a for
loop the operations done on each iteration through empty_pyramid2
will only affect the current element
(ie: ['*','*','*','*','*','*','*','*','*','*']
)
while each operation done on empty_pyramid
's current element is applied to the other elements as well.