Aug-18-2020, 12:45 PM
Hi,
Any idea why the while loop is not working?
Just noticed a mistake in my code, but still doesn't work:
Any idea why the while loop is not working?
homework = 'n' dinner = 'n' flag = False while (homework == 'n' or homework == 'N') and (dinner == 'n' or dinner == 'N'): if flag == True: print("Sorry you cant play xbox, lets try again:") homework = ("Did Harry complete his homework? (y/n") dinner = ("Did harry eat his dinner? (y/n") flag = True else: print("Great, well done Harry you can go and play Xbox")Thank you in advanced.
Just noticed a mistake in my code, but still doesn't work:
homework = 'n' dinner = 'n' flag = False while (homework == 'n' or homework == 'N') and (dinner == 'n' or dinner == 'N'): if flag == True: # when flag is true show the below statement print("Sorry you cant play xbox, lets try again:") homework = input("Did Harry complete his homework? (y/n): ") dinner = input("Did harry eat his dinner? (y/n): ") flag = True # will set flag to true else: print("Great, well done Harry you can go and play Xbox")when I enter y for the first question and n for the second, it then proceeds to show the else statement, rtaher than loop it as intended.