Discuss / Python / 交作业

交作业

Topic source

一定要注意print()的位置,python有严格的缩进,比如下面print定格,结果输出就只有最后一个值~

for  语句

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

for x in L:

    x='hello,'+x+'!'

    print(x)

n=2

while语句

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

while n>-1:

    m='Hello,'+L[n]+'!'

    print(m)

    n=n-1


  • 1

Reply