# 8-9
def show_magicians(magicians):
"""打印每个魔术师名字"""
for magician in magicians:
print(magician.title())
magicians = ['david stone', 'dan &dave', 'david copperfield']
show_magicians(magicians)
# 8-10
def show_magicians(magicians):
"""打印每个魔术师名字"""
for magician in magicians:
print(magician.title())
def make_great(magicians):
"""名字前加'the Great'"""
length = len(magicians)
for i in range(1, length+1):
magicians[i-1] = 'the Great ' + magicians[i-1]
magicians = ['david stone', 'dan &dave', 'david copperfield']
show_magicians(magicians)
make_great(magicians)
show_magicians(magicians)
# 8-11
def show_magicians(magicians):
"""打印每个魔术师名字"""
for magician in magicians:
print(magician.title())
def make_great(magicians):
"""名字前加'the Great'"""
length = len(magicians)
for i in range(1, length+1):
magicians[i-1] = 'the Great ' + magicians[i-1]
return(magicians)
magicians = ['david stone', 'dan &dave', 'david copperfield']
show_magicians(magicians)
magicians_new = make_great(magicians[:])
show_magicians(magicians_new)
show_magicians(magicians)
David Stone
Dan &Dave
David Copperfield
David Stone
Dan &Dave
David Copperfield
The Great David Stone
The Great Dan &Dave
The Great David Copperfield
David Stone
Dan &Dave
David Copperfield
The Great David Stone
The Great Dan &Dave
The Great David Copperfield
David Stone
Dan &Dave
David Copperfield
网友评论