如何解决这个问题 预期产出:
1 - that
2 - is
3 - weird
代码:
list = ['that', 'is', 'weird']
for i, k in range(list):
print str(i) + ' - ' + k
答案 0 :(得分:0)
尝试枚举而不是范围:
words = ['that', 'is', 'weird']
for i, k in enumerate(words):
print str(i) + ' - ' + k