In the following program, why do I need to use the name "player" rather than a regular counter like "i"? I ran the program this way and it prints out the last element in players for how ever many player elements are in players. I want to know what's going on behind the scenes, why is it choosing only the last element. Thanks.
# Simple Game
# Demonstrates importing modules
import games, random
print "Welcome to the world's simplest game!\n"
again = None
while again != "n":
players = []
num = games.ask_number(question = "How many players? (2 - 5): ",
low = 2, high = 5)
for i in range(num):
name = raw_input("Player name: ")
score = random.randrange(100) + 1
player = games.Player(name, score)
players.append(player)
print "\nHere are the game results:"
for player in players:
print player
again = games.ask_yes_no("\nDo you want to play again? (y/n): ")
raw_input("\n\nPress the enter key to exit.")