Funktion
Verfasst: Montag 8. April 2019, 13:35
Hi leute hänge grad fest an einer aufgabe undzwar
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 Greatto each magician’s name .Call show_magicians()to
see that the list has actually been modified .
def show_magicians(magicians):
""" print magicians names """
for magician in magicians:
print(magician)
magicians = ['freddy', 'robbin', 'krao']
show_magicians(magicians)
def make_great(magicians, great_mag):
""" build the print with the great """
while magicians:
magician = magicians.pop()
print(magician.title() + " the great ")
great_mag.append(magician)
for great_ma in great_mag:
magicians.append(great_ma)
magicians = ['freddy', 'robbin', 'krao']
great_mag = []
show_magicians(magicians)
print("\n")
make_great(magicians, great_mag)
show_magicians(magicians)
Und zwar sollte sich die liste zum schluss ändern aber sie bleibt immer noch die selbe könnt ihr mir helfen bitte ?
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 Greatto each magician’s name .Call show_magicians()to
see that the list has actually been modified .
def show_magicians(magicians):
""" print magicians names """
for magician in magicians:
print(magician)
magicians = ['freddy', 'robbin', 'krao']
show_magicians(magicians)
def make_great(magicians, great_mag):
""" build the print with the great """
while magicians:
magician = magicians.pop()
print(magician.title() + " the great ")
great_mag.append(magician)
for great_ma in great_mag:
magicians.append(great_ma)
magicians = ['freddy', 'robbin', 'krao']
great_mag = []
show_magicians(magicians)
print("\n")
make_great(magicians, great_mag)
show_magicians(magicians)
Und zwar sollte sich die liste zum schluss ändern aber sie bleibt immer noch die selbe könnt ihr mir helfen bitte ?