Sss123057057 发表于 2021-2-15 11:37:47

len

shoplist = ['apple', 'mango', 'carrot', 'banana']

print('I have', len(shoplist), 'items to purchase.')

print('These items are:', end=' ')
for item in shoplist:
    print(item, end=' ')


shoplist = ['apple', 'mango', 'carrot', 'banana']

print('I have', len(shoplist), 'items to purchase.')

print('These items are:', end=' ')
for item in len(shoplist):
    print(shoplist, end=' ')
why改动后出错

jackz007 发表于 2021-2-15 11:49:53

for item in len(shoplist):
      改为
for item in range(len(shoplist)):
页: [1]
查看完整版本: len