The problem is simple play a dice game rolling a pair of dice, count the number of rolls per “round” it takes to get double 6s, then ask the player to hit enter or q (or any other key) an enter starts a new round and a Q(or any other key) ends the game and simply gives an average for the rounds. They key press sections are giving me a ton of trouble unsure how to go about solving it but the dice game is very basic so im sure there is a technique im not looking at.

import random

averages =

def dicegame():

s = 0

t = 0

r = 0

while s < 12:

dice1 = random.randint(1,6)

dice2 = random.randint(1,6)

t = t + 1

s = dice1+dice2

if s == 12:

r += 1

print (‘Round #’, r, ’ took’, t, ‘rolls to get double sixes.’)

averages.append(t)

t = 0

avg = sum(averages)/len(averages)

return avg

I just need to figure out how to start the process over on a enter key, or stop it on any other keypress and only have it return the average on those alternative keypresses. Any suggestions would be much appreciated.