2 Replies - 216 Views - Last Post: 14 February 2019 - 07:33 AM Rate Topic: -----

#1 fmak916   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 14-June 18

Python Increment and report number of round in print statement

Posted 14 February 2019 - 04:56 AM

Hello

I am working on a mini dice game. I pretty much finish the game but I got stuck on how to increment counts for the print statement.
My output should be: Round # 1 You rolled a 6 and a 4, Round # 2 You rolled a 3 and a 2... / Round # 1 You rolled a 6 and a 6. You got a DOUBLE, Round # 2 6 and a 6. You got a DOUBLE.
any advice would be appreciated?? Thank you!!

#Homework 4 - Loops (randomness with dice)
import random

rollAgain = input('Do you want to roll again? Press Enter/Return to roll, n to quit')
count = 0
while count == 'y':
    count = count +1

while rollAgain != 'n' or rollAgain == 'y':    
    diceOne = random.randint(1, 6)
    diceTwo = random.randint(1, 6)

    if diceOne == diceTwo:
        print('Round#', int.count,'You rolled a', diceOne, 'and', 'a', diceTwo)
        print('You got DOUBLES!')
        print('You rolled a double. 16.6666667% chance')
    else:
        print('Round#', int.count, 'You rolled a', diceOne, 'and', 'a', diceTwo)
        
        rollAgain = input ('Do you want to roll again? Press Enter/Return to go again, n to quit ')




Is This A Good Question/Topic? 0
  • +

Replies To: Python Increment and report number of round in print statement

#2 DK3250   User is offline

  • Pythonian
  • member icon

Reputation: 507
  • View blog
  • Posts: 1,598
  • Joined: 27-December 13

Re: Python Increment and report number of round in print statement

Posted 14 February 2019 - 06:29 AM

Many small things:
1. the while loop in line 6 is strange, remove it
2. line 7 should be inside the main loop (after line 9)
3. 'int.count' in line 14 and 18 - where did you get this? should only be 'count'
4. line 20 should be outdented one level as it controls the while loop
5. line 9: " or rollAgain == 'y'" is superfluous.
Was This Post Helpful? 1
  • +
  • -

#3 fmak916   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 14-June 18

Re: Python Increment and report number of round in print statement

Posted 14 February 2019 - 07:33 AM

View PostDK3250, on 14 February 2019 - 06:29 AM, said:

Many small things:
1. the while loop in line 6 is strange, remove it
2. line 7 should be inside the main loop (after line 9)
3. 'int.count' in line 14 and 18 - where did you get this? should only be 'count'
4. line 20 should be outdented one level as it controls the while loop
5. line 9: " or rollAgain == 'y'" is superfluous.


Thanks for pointing out the small mistakes. Noted.

3. I was googling for a bit and I was just trying anything. : )

Thanks a bunch!!!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1