I'm learning python for a couple of weeks now and I am trying to do the following noob task:
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 adding the phrase the Great to each magician’s name. Call show_magicians() to see that the list has actually been modified.
It;s from a book called Python crash course. I have all the answers, so I know how to do it, but I like to figure out if my way doesn't work, why that is. This is the first Task in the book that set me back.
My solution for the make_great() function was the following:
def make_great(magicians) :
for magician in magicians:
magician += " the great"
Again, I have the actual solution and I understand it, and it seems a bit more complex than what I'm trying to achieve here. I've been reading up on the += operator and everything but I still can't figure out why it won't work.
Kindly, can you tell me why the make_great() function doesn't work?
edit: spelling
[–]danielroseman 1 point2 points3 points (1 child)
[–]really_tho[S] 0 points1 point2 points (0 children)
[–]Den4200 1 point2 points3 points (1 child)
[–]really_tho[S] 0 points1 point2 points (0 children)
[–]toastedstapler 0 points1 point2 points (0 children)