Discuss / Python / 作业

作业

Topic source

似水年华_

#1 Created at ... [Delete] [Delete and Lock User]

for..in..版本

L = ['Bart', 'Lisa', 'Adam'] for L in L: print('Hello,%s!'%L)

while 版本

L=['Bart', 'Lisa', 'Adam'] n=len(L)-1 while L: print('Hello,%s!'%L[n]) L.pop() n=n-1

能不能问下 在for in 循环中 我用的是for x in L 结果打印的是 hello + 整个数组 用了for L in L 后就输出正常了


  • 1

Reply