Discuss / Python / 三种写法

三种写法

Topic source

sina87602526

#1 Created at ... [Delete] [Delete and Lock User]
L = ['Bart', 'Lisa', 'Adam']
# 第一种
n = 0
while n < len(L):
    print('Hello,', L[n],'!')
    n += 1

# 第二种    
#n = 0
#while n < len(L):
#    print('Hello, %s!' % L[n])
#    n +=1

# 第三种
#for name in L:
#    print('Hello, %s!' % name)

  • 1

Reply