方法一:
# -*- coding: utf-8 -*- # 请利用循环依次对list中的每个名字打印出hello, xxx! l = ['bart', 'lisa', 'adam'] n = 0 while n < len(l): print('hello,' + l[n] + '!') n = n + 1
方法二:
# -*- coding: utf-8 -*- # 请利用循环依次对list中的每个名字打印出hello, xxx! l = ['bart', 'lisa', 'adam'] for x in l: print('hello,' + x + '!')