我正在试验列表,并试图显示以下代码段:
----------
---hello--
----------
但要做到这一点,我需要让 3 个“listSmall”彼此独立。有没有办法做到这一点?
(
当前输出当然是:
---hello--
---hello--
---hello--
)
listSmall = ['-','-','-','-','-','-','-','-','-','-',]
listBig = [listSmall, listSmall, listSmall]
word = 'hello'
wordPosX = 3
wordPosY = 2
for i in word:
listBig[wordPosY][wordPosX] = i
wordPosX = wordPosX + 1
i = 0
while i != 3:
print ''.join(listBig[i])
i = i + 1