Python入门习题大全——了不起的魔术师

Python入门习题大全——索引

在你为完成练习“魔术师”而编写的程序中,编写一个名为make_ great()的函数,对魔术师列表进行修改,在每个魔术师的名字中都加入字样“theGreat”。调用函数show_magicians(), 确认魔术师列表确实变了。

# 了不起的魔术师
def make_great(names):
    names = ["the great " + name for name in names]
    return names
def show_magicians(names):
    for name in names:
        print(name)

names = ['ling', 'hui', 'he']
names = make_great(names)
show_magicians(names)

输出为:

the great ling
the great hui
the great he
发布了269 篇原创文章 · 获赞 18 · 访问量 3万+

猜你喜欢

转载自blog.csdn.net/qq_43479432/article/details/105425586