I'm creating a dice game and I'm trying to break out of this infinite loop. Fixed by putting str on input so again=str(input('Roll again?')
import random
def play_again():
again = input('Would you like to roll again? ')
if again == 'y' or 'Y':
main()
if again == 'n' or 'N':
print('Exiting the game.')
def roll():
print('Rolling the dice.')
def exit():
print('Ending game.')
def result():
print('The number is '+str(random.randint(1,6))+'.')
def main():
roll()
result()
play_again()
main()
I know I could just put everything in one method, but I rather keep it the way it is. The program runs fine till it reaches play_again(). No matter what letter I press, it runs the program again. How would I fix it so it runs again if I press y and quit when I press n?