My code should make the Parrot
class randomly choose only one method of speaking, what the code currently does is repeat all the lines at the same time.
- Current output
This is my ninja way!
Hi, I am Goku!
Give me your strength Pegasus!
None
- Code
import random
class Naruto():
def talk1(self):
print("This is my ninja way!")
class Goku():
def talk2(self):
print("Hi, I am Goku!")
class Seiya():
def talk3(self):
print("Give me your strength Pegasus!")
class Parrot(Naruto, Goku, Seiya):
def repeat(self):
print(random.choice((super().talk1(), super().talk2(), super().talk3())))
parrot = Parrot()
parrot.repeat()
Aucun commentaire:
Enregistrer un commentaire