首页 > 代码库 > 20170417循环(loop)

20170417循环(loop)

1.for 循环

技术分享

①for num in range(1,11):
print(str(num)+‘ + 1 = ‘,num + 1)

②song_list = [‘Holy Diver‘,‘Thunderstruck‘,‘rebel rebel‘]
for song in song_list:
if song == ‘Holy Diver‘:
print(song,‘-Dio‘)
elif song == ‘Thunderstruck‘:
print(song,‘-AC/DC‘)
elif song == ‘rebel rebel‘:
print(song,‘- DAVAID BOWIE‘)

20170417循环(loop)