creek indy
creek indy

Reputation: 1

Basic Tally and Tracking

Hi thank you to anyone looking, I'm new in a beginners class. I have a game where a dealer and a player each guess a number and a random number is generated. Whoever is closest wins the round. After 5 rounds print("Dealer wins: Player wins: ") and the number of rounds won will populate in that print statement. If dealer tallied 3-5 wins print("Sorry Try Again") if player tallied 3-5 wins print("Congrats you win") I have have it looped but not set to end after five rounds and then can't figure out the tally which counts the rounds and prints the results.

while True:

 player = int(input("Guess a Number:"))
 print(player)

 dealer = int(input("Dealer Guess:"))
 print(dealer)

 import random

 num1 = random.randint(0, 100)

 print("Random Number:")

 print(num1)

 playerdist = abs(player - num1)

 dealerdist = abs(dealer - num1)

 if (playerdist > dealerdist):

   print("Dealer Wins")

 if (playerdist < dealerdist):

   print("Player Wins")

 if (playerdist == dealerdist):

   print("Draw")

Upvotes: 0

Views: 29

Answers (1)

min20120907
min20120907

Reputation: 186

Maybe you can add a iterator to count the rounds, if the rounds reached 5, then exits.

for i in 5:
 # rest of the codes

Upvotes: 1

Related Questions