Discuss / Python / 作业

作业

Topic source

Run_Donitz

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

你好,请问你在

while x<3:
    print('Hello,'+L[x]+'!')
    x=x+1

中print中L[x]里加两个括号有什么作用?

L是个list,L[x]指向list中的str打印,不然会出现typeError


  • 1

Reply