Function is passed a list of exercises

Use of knowledge:

1, a list of functions that can be passed

2, the function can modify the list

3. If you do not want to modify the list with a function, you can use function_name (LIST_NAME : []) Creates a copy of the list, a copy of the list to operate.

 

Magician unchanged: to complete the exercise and modify your programs written 8-10, when you call the function make_great (), passing it a copy of the magician list. Did not want to modify the original list, please return the modified list, and store it to another list. Both lists were used to call show_magicians (), confirm a list containing the name of the original magician, and the other contains the list is the addition of the words "the Great" magician name. 

 

 

def show_magicians(names):
    for name in names:
        print(name.title())

def make_great(names):
    for i in range(len(great_names)):
        great_names[i]='The great '+great_names[i]
    return great_names

magicians_names = ['hong tao','xiao weihong','hong yumi','hong yuchan']

great_names=magicians_names[:]

make_great(great_names)

show_magicians(magicians_names)

show_magicians(great_names)

 

Guess you like

Origin www.cnblogs.com/show530/p/12469366.html