Discuss / Python / 交作业2019.2.13

交作业2019.2.13

Topic source

for x in ...

# -*- coding: utf-8 -*-
L = ['Bart', 'Lisa', 'Adam']
for name in L:
    print('Hello,%s!'%name)

while

# -*- coding: utf-8 -*-
L = ['Bart', 'Lisa', 'Adam']
n=0
while n < len(L):
    print('Hello,%s!' %L[n])
    n=n+1

输出结果:

Hello,Bart!
Hello,Lisa!
Hello,Adam!

  • 1

Reply