Discuss / Python / 练习

练习

Topic source

-- coding: utf-8 --

L=['Bart','Lisa','Adam'] n=0

1.用while

while n<len(L): print(L[n]) n=n+1 print()

2.用for

for x in L: print(x)

Endless_V

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

while那个写的漂亮,我只是想到了可以用len(),于是多添加了一个变量控制len()自减,然后while条件是len()>0,但没想到可以用i和len(L)作比较,真是涨姿势了~


  • 1

Reply