-1

I have this code I wrote partly on my own, and some with help from other posts that I changed. when I type y, while running the program it will continue the loop, but when I say yes it exits. Is there a different input I need? How can I fix this code?

from random import randint
repeat = 'y'
while repeat == ('y' or 'yes'):
    print('your dice is',randint(1,6))
    print('Do you want to roll again?')
    repeat = input().lower()
else:
    print('have a nice day')
Karl Knechtel
  • 62,466
  • 11
  • 102
  • 153
gatorcoder
  • 371
  • 2
  • 5

1 Answers1

0

The problem is in repeat == ('y' or 'yes'):

You'll either want to test the user input against each valid string, like this:

while repeat == 'y' or repeat == 'yes':

or maybe easier to test against the strings in a list:

while repeat in ['y', 'yes']:

Hope that helps.