I'm reading the Python Crash Course book by Eric Matthes, and I'm working on this exercise:
8-9. Magicians: Make a list of magician’s names . Pass the list to a function called
show_magicians(), which prints the name of each magician in the list .8-10. Great Magicians: Start with a copy of your program from Exercise 8-9 . Write a function called
make_great()that modifies the list of magicians by add- ing the phrase the Great to each magician’s name . Callshow_magicians()to see that the list has actually been modified .
In his book he modifies lists by passing them as arguments in a function, and that function changes the list, but all I get is a list of the original names. What did I do wrong?
def show_magicians(magicians):
for magician in magicians:
print(magician.title())
def make_great(magicians):
for magician in magicians:
magician = "Great " + magician
magicians = ['hermione','mihai','harry potter', 'voldemort']
make_great(magicians)
show_magicians(magicians)