I have the following python code:
def make_great(l):
l = [\'The great \' + magician for magician in l]
magicians = [\'Tom\']
make_great(magicians)
print(mag
When you assign it to l
, you are redefining l
, not modifying it. Use l[:]
instead:
def make_great(l):
l[:] = ['The great ' + magician for magician in l]
You could also return the list and redefine magicians
:
def make_great(l):
return ['The great ' + magician for magician in l]
magicians = ['Tom']
magicians = make_great(magicians)
print(magicians)
In that case, you could assign magicians
to make_great(['Tom'])
:
magicians = make_great(['Tom'])
print(magicians)