Discuss / Python / 都是用for语句,想试试用while,结果发现比for麻烦多了

都是用for语句,想试试用while,结果发现比for麻烦多了

Topic source

AndyRCX

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

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

a=len(L)

i=0

while a>=1:

name=L[i]

print('hello ',name,'!')

i=i+1

a=a-1

Agoni52Hz_

#2 Created at ... [Delete] [Delete and Lock User]
L = ['Bart', 'Lisa', 'Adam']i = len(L)a = 0while a < i:    name = L[a]    print("hello,",name+"!")    a += 1

  • 1

Reply