1

I'm creating a Hangman game for a class proyect, and I would like to iterate a list which represents the turns of a determinate number of players.

dic_players = {0: 'Juan',1: 'Pepe',2: 'Luis'}
player_turns = [2,1,0]

How would you iterate "player_turns" multiple times? If they don't get removed from the game (The value in the original dictionary is a list with multiple numbers, some represent number of fails and stuff), the turns would be 'Luis', 'Pepe', 'Juan', 'Luis', 'Pepe', 'Juan' and so

miradulo
  • 28,857
  • 6
  • 80
  • 93
iLu Anzu
  • 23
  • 6

1 Answers1

0

You need a double for loop. You need to iterate over the number of rounds in the game, and for each round you need to iterate over the all the players.

for round in range(3): print('round %d' % round) for playerId in player_turns: print('%s\'s turn' % dic_players[playerId]) # do stuff