I'm trying to pass a copy of a list to a function in python so I can pop and append to a new list without losing the information in the old list. But I'm having trouble.
here's my code
def show_magicians(magicians):
for magician in magicians:
print (magician.title())
return magicians
def make_great(magicians):
for magician in magicians:
new_magician = magicians.pop()
new_magicians.append(new_magician)
print (new_magician.title() + ", is a great magician!!")
return magicians
new_magicians = []
magicians = ['merlin', 'blaine', 'agaybi', 'copperfield']
show_magicians(magicians)
make_great(magicians[:])
print ('\n' , magicians)
print ('\n' , new_magicians)
The second function is supposed to move the elements from the old list to the new and print the simple statement for each one without emptying the old list. The problem is I get only 1 element printed and the same element is the only element moved.
What am I doing wrong?
make_great, trynew_magicians = make_great(magicians[:]).[:]. The problem is that that's unrelated tonew_magicians!new_magicians.append(...)though.