#Print magician and their name with 'the great' in front of them
magician = ['Diedle','kuler','Gargon']
changed_magician = []
def show_magicians(mag):
print('The magician that will be presented are:')
for magi in mag:
print(magi.title())
def make_great(magic,magical):
for magici in magic:
magici = magic.pop(0)
magici = "The Great " +magici
magical.append(magici)
make_great(magician[:],changed_magician)
show_magicians(magician)
show_magicians(changed_magician)
It outputs:
The magician that will be presented are:
Diedle
Kuler
Gargon
The magician that will be presented are:
The Great Diedle
The Great Kuler
I want it to output:
The magician that will be presented are:
Diedle
Kuler
Gargon
The magician that will be presented are:
The Great Diedle
The Great Kuler
The Great Gargon
Essentially, I wish there will be The Great Gargon, too. Does anyone know how to do it?
I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.
See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.
Why are you passing magician into the function make_great like this:
make_great(magician[:],changed_magician)
Also, why are you passing two global variables into a function as arguments without needing them to be changed?
That is, you could just have this as the last line in your make_great function:
Hi, thanks for the feedback. I am a beginner of Python. At this moment I really don’t know any line that will achieve my objection. I believe you know something. Do you mind give me the code directly?