Discuss / Python / 两种方法。

两种方法。

Topic source

首先是while方法:

L = ['Bart','Lisa','Adam']
a = 0
while a < len(L):
    print('Hello,%s!'%L[a])
    a += 1

然后是for方法:

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

  • 1

Reply