Skip to content

Instantly share code, notes, and snippets.

@brez
Created October 12, 2015 00:17
Show Gist options
  • Save brez/08e035331ae19435fe42 to your computer and use it in GitHub Desktop.
Save brez/08e035331ae19435fe42 to your computer and use it in GitHub Desktop.
players = []
class Players(object):
"""create a Player for each user who answers questions in get_guess()"""
def __init__(self, name, guess, points):
self.name = name
self.guess = guess
self.points = points
def __str__(self):
return "%s, has guess: %s and %d points" % (self.name, self.guess, self.points)
def get_guess():
"""ask questions to user, set variables from their responses"""
name = raw_input("Please enter your name ")
guess = raw_input("Who will win Game 1, the Dodgers or the Cardinals?")
print "Hello %s, you guessed %s will win Game 1.\nGood Luck!" % (name, guess)
players.append(Players(name, guess, 0))
more_players = raw_input("Are there any other players?")
while more_players == "yes":
name = raw_input("Please enter your name ")
guess = raw_input("Who will win Game 1, the Dodgers or the Cardinals?")
print "Hello %s, you guessed %s will win Game 1.\nGood Luck!" % (name, guess)
players.append(Players(name, guess, 0))
more_players = raw_input("Are there any other players?")
get_guess()
for player in players:
print player
@brez
Copy link
Author

brez commented Oct 12, 2015

$ python players.py 
Please enter your name brez
Who will win Game 1, the Dodgers or the Cardinals? Jets 
Hello brez, you guessed  Jets will win Game 1.
Good Luck!
Are there any other players? no
brez, has guess:  Jets and 0 points

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment