I'm trying to execute the following code:
class PlayerControl:
def __init__(self):
self.player_menu = views.PlayerMenu()
self.player_model = models.Player()
def main():
choice = views.PlayerMenu.main()
if choice == "1":
if type(models.Player.list_not_participants()) == None:
print("Aucun joueur disponible.")
PlayerControl.create_players()
else:
PlayerControl.select_players()
elif choice == "2":
PlayerControl.create_player()
elif choice == "q":
sys.exit()
else:
PlayerControl.main()
And I'm getting the following output if I type "1" and the type is indeed None:
Aucun joueur disponible.
Aucun joueur disponible.
Traceback (most recent call last):
[...] TypeError: 'NoneType' object is not iterable
It looks like the code is executing twice while respecting the "if" condition and a third time without doing so. I've looked into the other answers available on StackOverflow, but it's not a problem of mutual import...
It's probably a very silly mistake because I'm a beginner, but I'm really stuck on that one. Thank you in advance for your help!
Aucun commentaire:
Enregistrer un commentaire