I have to make this game for my comp class, and I can't figure out how how break out of this loop.
I have to play against the "computer," by rolling bigger numbers, and seeing who has the bigger score. But I can't figure out how to "break" from my turn, and transition to the computers turn. I need "Q" (quit) to signal the beginning of the computers turn, but I don't know how to do it.
ans = 'R'
while True:
print('Your score is so far ' + str(myScore) + '.')
print("Would you like to roll or quit?")
ans = input("Roll...")
if ans == 'R':
R = random.randint(1, 8)
print("You rolled a " + str(R) + ".")
myScore = R + myScore
if ans == 'Q':
print("Now I'll see if I can break your score...")
break
breakthe way you are is fine, but you have to type exactlyQ.qwon't work for example. Is the first line supposed to sayans=('R')? you don't need it anyway