I'm still learning the basics of python and can't seem to figure out why my simple dice rolling code isn't working properly.
import random
def main():
num = int(input("How many sides of the die?\n"))
num_of_rolls = int(input("How many rolls?\n"))
roll_y_n = input("Are you ready to roll? Y/N\n")
var = 1
def dice_roll(num):
return random.randrange(1,num)
if roll_y_n.lower() in "yes" or "y":
while var <= num_of_rolls:
print("You rolled a " + str(dice_roll(num)) + ".")
var = var + 1
else:
print("Okay, Byeee!")
exit()
retry = input("Do you want to go again? Y/N\n")
if retry.lower() == "yes" or "y":
main()
elif retry in "no" or 'n':
print("Okay, Byeee!")
exit()
main()
it runs it just fine, but when ever I type in "n" to get it to stop it still runs as if I typed in "y". Sorry if this is a dumb question, I just can't figure it out.