I wrote the code on my own for this task as shown below:
def showmagicians(magician_names):
for name in magician_names:
print(name)
def make_great(magician_names):
the_greats = []
**for name in magician_names:**
the_great = name +'_the_great'
pop_name = magician_names.pop()
the_greats.append(the_great)
for the_great in the_greats:
magician_names.append(the_great)
return magician_names
magician_names = ['harry','david']
showmagicians(magician_names)
make_great(magician_names)
print(magician_names)
**Output:
harry
david
['harry', 'harry_the_great']**
I didn't use 'while' statement in the ‘make_great function’, I used 'for' statement, and the output is wrong. But I can't see there is a difference between the two.
The task requires us to output the 'magician_names' with 'the great' suffix. The code provided by the book is listed here: https://ehmatthes.github.io/pcc/solutions/chapter_8.html#8-6-city-names Can someone tell me what's the difference???