Python Forum
important work. need help urgently please
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
important work. need help urgently please
#5
(Feb-11-2021, 05:15 AM)deanhystad Wrote: import randomfrom time import sleep def get_players():    """Get players names and initialize scores"""    players = []    for i in range(2):        players.append({'name':input('Enter Player {i+1} Name: '), 'score':0})    return players def roll_dice(players):    """Give each player a turn.  Players roll two dice.  Players are awarded    the total of the two dice. If the total is even, the player is awarded    a 10 point bonus.  If the total is odd, the player is penalized 5 points.    If the player rolls doubles they roll an additional die and are awarded    a bonus equal to the value of the die.    """ def play_game(players):    """Play the dice game.  Players get 4 rolls and the player with the highest    score wins.  If players are tied after 4 rolls they continue to roll until    the tie is broken.    """    for _ in range(4):        roll_dice(players)     while players[0]['score'] == players[1]['score']:        print('The score is tied!  Tiebreaker roll!')        roll_dice(players)     if players[0]['score'] > players[1]['score']:        winner, loser = players    else:        loser, winner = players    print(f'\n{winner["name"]} wins with {winner["score"]} points!')    print(f'{loser["name"]} finishes with {loser["score"]} points\n\n') players = get_players()play_game(players)
where would I put that ? do I replace the roll function with that
Reply


Messages In This Thread
RE: important work. need help urgently please - by hola123 - Feb-11-2021, 09:39 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  I need help with a python Rock Paper Scissors game urgently. Riff_Raff 3 8,652 Dec-05-2018, 09:13 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020